Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
More test data and an actual test.
James Coleb13b58a2b275
diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.phpindex 937998ea38..67e4ad7d2d 100644--- a/database/seeds/TestDataSeeder.php+++ b/database/seeds/TestDataSeeder.php@@ -1,5 +1,7 @@<?php+use FireflyIII\Models\Account;+use FireflyIII\Models\AccountMeta;use FireflyIII\User;use Illuminate\Database\Seeder;@@ -15,7 +17,45 @@ class TestDataSeeder extends Seeder*/public function run(){- User::create(['email' => '[email protected]', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);+ $user = User::create(['email' => '[email protected]', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);+ $emptyUser = User::create(['email' => '[email protected]', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);++ // create asset accounts for user #1.+ $this->createAssetAccounts($user);+ }++ /**+ * @param User $user+ */+ private function createAssetAccounts(User $user)+ {+ $assets = ['TestData Checking Account', 'TestData Savings', 'TestData Shared', 'TestData Creditcard', 'Emergencies', 'STE'];+ $ibans = ['NL47JDYU6179706202', 'NL51WGBP5832453599', 'NL81RCQZ7160379858', 'NL19NRAP2367994221', 'NL40UKBK3619908726', 'NL38SRMN4325934708'];+ $assetMeta = [+ ['accountRole' => 'defaultAsset'],+ ['accountRole' => 'savingAsset',],+ ['accountRole' => 'sharedAsset',],+ ['accountRole' => 'ccAsset', 'ccMonthlyPaymentDate' => '2015-05-27', 'ccType' => 'monthlyFull',],+ ['accountRole' => 'savingAsset',],+ ['accountRole' => 'savingAsset',],+ ];++ foreach ($assets as $index => $name) {+ // create account:+ $account = Account::create(+ [+ 'user_id' => $user->id,+ 'account_type_id' => 3,+ 'name' => $name,+ 'active' => 1,+ 'encrypted' => 1,+ 'iban' => $ibans[$index],+ ]+ );+ foreach ($assetMeta[$index] as $name => $value) {+ AccountMeta::create(['account_id' => $account->id, 'name' => $name, 'data' => $value,]);+ }+ }}}diff --git a/tests/BasicTest.php b/tests/BasicTest.phpindex 079f2790df..ee499b9359 100644--- a/tests/BasicTest.php+++ b/tests/BasicTest.php@@ -13,5 +13,6 @@ class BasicTest extends TestCasepublic function testExample(){$this->assertTrue(true);+}}diff --git a/tests/TestCase.php b/tests/TestCase.phpindex 954bf15880..3f5e19ebcf 100755--- a/tests/TestCase.php+++ b/tests/TestCase.php@@ -1,5 +1,6 @@<?phpuse Carbon\Carbon;+use FireflyIII\User;/*** Class TestCase@@ -27,6 +28,23 @@ class TestCase extends Illuminate\Foundation\Testing\TestCasereturn $app;}+ /**+ * @return User+ */+ public function user()+ {+ return User::find(1);+ }++ /**+ * @return User+ */+ public function emptyUser()+ {+ return User::find(2);+ }++/*** Sets up the fixture, for example, opens a network connection.* This method is called before a test is executed.diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.phpnew file mode 100644index 0000000000..23d725bb8e--- /dev/null+++ b/tests/acceptance/Controllers/HomeControllerTest.php@@ -0,0 +1,28 @@+<?php++/**+ * HomeControllerTest.php+ * Copyright (C) 2016 Sander Dorigo+ *+ * This software may be modified and distributed under the terms+ * of the MIT license. See the LICENSE file for details.+ */+class HomeControllerTest extends TestCase+{+ public function testDateRange()+ {++ $this->be($this->user());++ $args = [+ 'start' => '2012-01-01',+ 'end' => '2012-04-01',+ ];++ // if date range is > 50, should have flash.+ $response = $this->call('POST', '/daterange', $args);+ $this->assertEquals(200, $response->status());+ $this->assertSessionHas('warning', '91 days of data may take a while to load.');+ }++}\ No newline at end of file