From b4a401700e9a4a9aa21501eebe1d3ddf5bfed775 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 2 Jul 2015 09:44:56 +0200 Subject: [PATCH] Installed codeception. --- tests/TestCase.php | 111 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 tests/TestCase.php diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000000..8b972b79d0 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,111 @@ +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; + } + + +}