From a8d01550dcec54bf8c86dc13d7a4b8d903761266 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Nov 2013 08:09:14 -0500 Subject: [PATCH] Prep for unit testing --- app/config/testing/database.php | 14 ++++++++++++++ app/tests/TestCase.php | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 app/config/testing/database.php diff --git a/app/config/testing/database.php b/app/config/testing/database.php new file mode 100644 index 0000000000..b15c97c575 --- /dev/null +++ b/app/config/testing/database.php @@ -0,0 +1,14 @@ + 'sqlite', + + 'connections' => array( + 'sqlite' => array( + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '' + ), + ) +); \ No newline at end of file diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php index 49b80fc274..c9f4d33996 100755 --- a/app/tests/TestCase.php +++ b/app/tests/TestCase.php @@ -2,6 +2,18 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase { + /** + * Default preparation for each test + * + */ + public function setUp() + { + parent::setUp(); // Don't forget this! + + $this->prepareForTests(); + } + + /** * Creates the application. * @@ -16,4 +28,15 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase { return require __DIR__.'/../../bootstrap/start.php'; } + /** + * Migrates the database and set the mailer to 'pretend'. + * This will cause the tests to run quickly. + * + */ + private function prepareForTests() + { + Artisan::call('migrate'); + Mail::pretend(true); + } + }