mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-03 20:56:21 +00:00
Some new code for testing.
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user