mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-24 16:10:37 -06:00
Some new code for testing.
This commit is contained in:
parent
e834489206
commit
deaebc373c
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@ storage/
|
||||
.project
|
||||
.settings/
|
||||
|
||||
.env.local
|
||||
|
@ -48,7 +48,7 @@ return [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => storage_path('database.sqlite'),
|
||||
'database' => storage_path('database') . '/testing.db',
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
|
@ -22,9 +22,15 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call('TransactionTypeSeeder');
|
||||
$this->call('PermissionSeeder');
|
||||
|
||||
if (App::environment() == 'testing' || App::environment() == 'homestead' || gethostname() == 'lightning') {
|
||||
// set up basic test data (as little as possible):
|
||||
if (App::environment() == 'testing') {
|
||||
$this->call('TestDataSeeder');
|
||||
}
|
||||
|
||||
// this one is reserved for more extensive testing.
|
||||
//if (App::environment() == 'testing' || App::environment() == 'homestead' || gethostname() == 'lightning') {
|
||||
//$this->call('VisualTestDataSeeder');
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
1424
database/seeds/VisualTestDataSeeder.php
Normal file
1424
database/seeds/VisualTestDataSeeder.php
Normal file
File diff suppressed because it is too large
Load Diff
41
pu.sh
Executable file
41
pu.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set testing environment
|
||||
cp .env.testing .env
|
||||
|
||||
# test!
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
#phpunit --verbose
|
||||
phpunit
|
||||
fi
|
||||
|
||||
# directories to look in:
|
||||
#dirs=("controllers" "database" "factories" "generators" "helpers" "models" "middleware" "repositories" "support")
|
||||
#
|
||||
#if [ ! -z "$1" ]
|
||||
#then
|
||||
# for i in "${dirs[@]}"
|
||||
# do
|
||||
# firstFile="./tests/$i/$1.php"
|
||||
# secondFile="./tests/$i/$1Test.php"
|
||||
# if [ -f "$firstFile" ]
|
||||
# then
|
||||
# # run it!
|
||||
# phpunit --verbose $firstFile
|
||||
# exit $?
|
||||
# fi
|
||||
# if [ -f "$secondFile" ]
|
||||
# then
|
||||
# # run it!
|
||||
# phpunit --verbose $secondFile
|
||||
# exit $?
|
||||
# fi
|
||||
#
|
||||
#
|
||||
# done
|
||||
#
|
||||
#fi
|
||||
|
||||
# restore .env file
|
||||
cp .env.local .env
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class TestCase
|
||||
@ -19,10 +20,61 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// if the database copy does not exist, call migrate.
|
||||
$copy = storage_path('database') . '/testing-copy.db';
|
||||
$original = storage_path('database') . '/testing.db';
|
||||
|
||||
// move .env file over?
|
||||
if (!file_exists($copy)) {
|
||||
touch($original);
|
||||
Artisan::call('migrate', ['--seed' => true]);
|
||||
copy($original, $copy);
|
||||
} else {
|
||||
if (file_exists($copy)) {
|
||||
copy($copy, $original);
|
||||
}
|
||||
}
|
||||
// if the database copy does exists, copy back as original.
|
||||
|
||||
$this->session(
|
||||
[
|
||||
'start' => Carbon::now()->startOfMonth(),
|
||||
'end' => Carbon::now()->endOfMonth(),
|
||||
'first' => Carbon::now()->startOfYear(),
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
// delete copy original.
|
||||
//$original = __DIR__.'/../storage/database/testing.db';
|
||||
//unlink($original);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user