mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Installed codeception.
This commit is contained in:
parent
e9601bb9c1
commit
b4a401700e
111
tests/TestCase.php
Normal file
111
tests/TestCase.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TestCase
|
||||||
|
*/
|
||||||
|
class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||||
|
{
|
||||||
|
protected $baseUrl = 'http://localhost';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the application.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Foundation\Application
|
||||||
|
*/
|
||||||
|
public function createApplication()
|
||||||
|
{
|
||||||
|
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||||
|
|
||||||
|
$app->make('Illuminate\Contracts\Console\Kernel')->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 = __DIR__ . '/../storage/database/testing-copy.db';
|
||||||
|
$original = __DIR__ . '/../storage/database/testing.db';
|
||||||
|
|
||||||
|
FactoryMuffin::loadFactories(__DIR__ . '/factories');
|
||||||
|
|
||||||
|
if (!file_exists($copy)) {
|
||||||
|
touch($original);
|
||||||
|
Artisan::call('migrate');
|
||||||
|
|
||||||
|
|
||||||
|
// create EUR currency
|
||||||
|
/** @var TransactionCurrency $currency */
|
||||||
|
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||||
|
$currency->code = 'EUR';
|
||||||
|
$currency->save();
|
||||||
|
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()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called before the first test of this test class is run.
|
||||||
|
*
|
||||||
|
* @since Method available since Release 3.4.0
|
||||||
|
*/
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
parent::setUpBeforeClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $class
|
||||||
|
*
|
||||||
|
* @return Mockery\MockInterface
|
||||||
|
*/
|
||||||
|
public function mock($class)
|
||||||
|
{
|
||||||
|
$mock = Mockery::mock($class);
|
||||||
|
|
||||||
|
$this->app->instance($class, $mock);
|
||||||
|
|
||||||
|
return $mock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user