Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Expanded tests.
James Cole0f12ebb31c31
diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.phpindex b0412960f6..682299f4d3 100644--- a/app/Http/Controllers/JsonController.php+++ b/app/Http/Controllers/JsonController.php@@ -4,8 +4,6 @@ use Amount;use Carbon\Carbon;use Config;use FireflyIII\Helpers\Report\ReportQueryInterface;-use FireflyIII\Models\RuleAction;-use FireflyIII\Models\RuleTrigger;use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;use FireflyIII\Repositories\Bill\BillRepositoryInterface;use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;@@ -48,7 +46,6 @@ class JsonController extends Controller$view = view('rules.partials.action', compact('actions', 'count'))->render();-return Response::json(['html' => $view]);}diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.phpindex 14ee71d02a..5141a751d0 100755--- a/database/factories/ModelFactory.php+++ b/database/factories/ModelFactory.php@@ -1,21 +1,21 @@<?php-/*-|---------------------------------------------------------------------------| Model Factories-|---------------------------------------------------------------------------|-| Here you may define all of your model factories. Model factories give-| you a convenient way to create models for testing and seeding your-| database. Just tell the factory how a default model should look.-|-*/--$factory->define(FireflyIII\User::class, function (Faker\Generator $faker) {+$factory->define(+ FireflyIII\User::class, function (Faker\Generator $faker) {return [- 'name' => $faker->name,- 'email' => $faker->email,- 'password' => bcrypt(str_random(10)),+ 'name' => $faker->name,+ 'email' => $faker->email,+ 'password' => bcrypt(str_random(10)),'remember_token' => str_random(10),];-});+}+);++$factory->define(+ FireflyIII\Models\TransactionType::class, function (Faker\Generator $faker) {+ return [+ 'type' => $faker->name,+ ];+}+);+diff --git a/tests/acceptance/Controllers/JsonControllerTest.php b/tests/acceptance/Controllers/JsonControllerTest.phpindex fa5861b60d..b06d53987c 100644--- a/tests/acceptance/Controllers/JsonControllerTest.php+++ b/tests/acceptance/Controllers/JsonControllerTest.php@@ -6,6 +6,7 @@* This software may be modified and distributed under the terms* of the MIT license. See the LICENSE file for details.*/+use Illuminate\Support\Collection;/**@@ -16,157 +17,138 @@ class JsonControllerTest extends TestCase/*** @covers FireflyIII\Http\Controllers\JsonController::action- * @todo Implement testAction().*/public function testAction(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/action');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid- * @todo Implement testBoxBillsPaid().*/public function testBoxBillsPaid(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/box/bills-paid');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid- * @todo Implement testBoxBillsUnpaid().*/public function testBoxBillsUnpaid(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/box/bills-unpaid');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::boxIn- * @todo Implement testBoxIn().*/public function testBoxIn(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/box/in');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::boxOut- * @todo Implement testBoxOut().*/public function testBoxOut(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/box/out');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::categories- * @todo Implement testCategories().*/public function testCategories(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/categories');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::endTour- * @todo Implement testEndTour().*/public function testEndTour(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('POST', '/json/end-tour');+ $this->assertEquals(200, $response->status());+ $this->assertEquals('"true"', $response->content());}/*** @covers FireflyIII\Http\Controllers\JsonController::expenseAccounts- * @todo Implement testExpenseAccounts().*/public function testExpenseAccounts(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/expense-accounts');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::revenueAccounts- * @todo Implement testRevenueAccounts().*/public function testRevenueAccounts(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/revenue-accounts');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::tags- * @todo Implement testTags().*/public function testTags(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/tags');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::tour- * @todo Implement testTour().*/public function testTour(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/tour');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::transactionJournals- * @todo Implement testTransactionJournals().*/public function testTransactionJournals(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $type = factory(FireflyIII\Models\TransactionType::class)->make();+ $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');++ $repository->shouldReceive('getTransactionType')->with('deposit')->once()->andReturn($type);+ $repository->shouldReceive('getJournalsOfType')->with($type)->once()->andReturn(new Collection);++ $this->be($this->user());+ $response = $this->call('GET', '/json/transaction-journals/deposit');+ $this->assertEquals(200, $response->status());}/*** @covers FireflyIII\Http\Controllers\JsonController::trigger- * @todo Implement testTrigger().*/public function testTrigger(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $response = $this->call('GET', '/json/trigger');+ $this->assertEquals(200, $response->status());}}