Skip to content

Firefly III: a personal finances manager

New tests and new configuration for tests.

James Cole584f7ced848c
diff --git a/app/config/testingInMemory/app.php b/app/config/testingInMemory/app.php
new file mode 100644
index 0000000000..e729eb5ab7
--- /dev/null
+++ b/app/config/testingInMemory/app.php
@@ -0,0 +1,2 @@
+<?php
+return ['log_level' => 'debug',];
\ No newline at end of file
diff --git a/app/config/testingInMemory/auth.php b/app/config/testingInMemory/auth.php
new file mode 100644
index 0000000000..0fe9e0172d
--- /dev/null
+++ b/app/config/testingInMemory/auth.php
@@ -0,0 +1,8 @@
+<?php
+
+return [
+ 'verify_mail' => false,
+ 'verify_reset' => true,
+ 'allow_register' => true
+
+];
diff --git a/app/config/testingInMemory/cache.php b/app/config/testingInMemory/cache.php
new file mode 100644
index 0000000000..fef1e78b52
--- /dev/null
+++ b/app/config/testingInMemory/cache.php
@@ -0,0 +1,3 @@
+<?php
+
+return ['driver' => 'array',];
diff --git a/app/config/testingInMemory/database.php b/app/config/testingInMemory/database.php
new file mode 100644
index 0000000000..0472797a15
--- /dev/null
+++ b/app/config/testingInMemory/database.php
@@ -0,0 +1,12 @@
+<?php
+return [
+ 'default' => 'sqlite',
+ 'connections' => [
+ 'sqlite' => [
+ 'driver' => 'sqlite',
+ 'database' => ':memory:',
+ 'prefix' => ''
+ ]
+
+ ]
+];
\ No newline at end of file
diff --git a/app/config/testingInMemory/mail.php b/app/config/testingInMemory/mail.php
new file mode 100644
index 0000000000..d2df78f4cd
--- /dev/null
+++ b/app/config/testingInMemory/mail.php
@@ -0,0 +1,13 @@
+<?php
+
+return [
+ 'driver' => 'smtp',
+ 'host' => '',
+ 'port' => 587,
+ 'from' => ['address' => '', 'name' => 'Firefly III'],
+ 'encryption' => 'tls',
+ 'username' => '',
+ 'password' => '',
+ 'sendmail' => '/usr/sbin/sendmail -bs',
+ 'pretend' => true,
+];
diff --git a/app/config/testingInMemory/session.php b/app/config/testingInMemory/session.php
new file mode 100644
index 0000000000..fef1e78b52
--- /dev/null
+++ b/app/config/testingInMemory/session.php
@@ -0,0 +1,3 @@
+<?php
+
+return ['driver' => 'array',];
diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php
index 7b3950fc48..295da78ad4 100644
--- a/app/tests/TestCase.php
+++ b/app/tests/TestCase.php
@@ -16,7 +16,8 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
public function createApplication()
{
$unitTesting = true;
- $testEnvironment = 'testing';
+ $testEnvironment = 'testingInMemory';
+
return require __DIR__ . '/../../bootstrap/start.php';
@@ -25,6 +26,9 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
public function setUp()
{
parent::setUp();
+ // reset database?
+ $this->prepareForTests();
+
}
static public function setupBeforeClass()
@@ -37,4 +41,15 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
{
//m::close();
}
+
+ /**
+ * 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);
+ }
}
\ No newline at end of file
diff --git a/app/tests/factories/Budget.php b/app/tests/factories/Budget.php
new file mode 100644
index 0000000000..1975cf53b0
--- /dev/null
+++ b/app/tests/factories/Budget.php
@@ -0,0 +1,8 @@
+<?php
+
+League\FactoryMuffin\Facade::define(
+ 'Budget', [
+ 'name' => 'word',
+ 'user_id' => 'factory|User'
+ ]
+);
diff --git a/tests/unit/AccountTypeTest.php b/tests/unit/AccountTypeTest.php
new file mode 100644
index 0000000000..c0d29759ed
--- /dev/null
+++ b/tests/unit/AccountTypeTest.php
@@ -0,0 +1,27 @@
+<?php
+use League\FactoryMuffin\Facade as f;
+
+/**
+ * Class AccountTypeTest
+ */
+class AccountTypeTest extends TestCase
+{
+
+ public function setUp()
+ {
+ parent::setUp();
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ }
+
+ // tests
+ public function testAccounts()
+ {
+ $account = f::create('Account');
+ $this->assertCount(1, $account->accountType()->first()->accounts()->get());
+ }
+
+}
\ No newline at end of file
diff --git a/tests/unit/BudgetTest.php b/tests/unit/BudgetTest.php
new file mode 100644
index 0000000000..9ee9b4aaad
--- /dev/null
+++ b/tests/unit/BudgetTest.php
@@ -0,0 +1,26 @@
+<?php
+use League\FactoryMuffin\Facade as f;
+
+/**
+ * Class AccountTypeTest
+ */
+class BudgetTest extends TestCase
+{
+
+ public function setUp()
+ {
+ parent::setUp();
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ }
+
+ public function testUser()
+ {
+ $budget = f::create('Budget');
+ $this->assertInstanceOf('User', $budget->user);
+
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/ExamplATest.php b/tests/unit/ExamplATest.php
deleted file mode 100644
index 40e171dbf2..0000000000
--- a/tests/unit/ExamplATest.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-class ExamplATest extends \PHPUnit_Framework_TestCase
-{
- protected function setUp()
- {
- }
-
- protected function tearDown()
- {
- }
-
- // tests
- public function testMe()
- {
- }
-
-}
\ No newline at end of file