From eaf2667abb5b1b0f6293620adbfc684bdad1749f Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 2 Sep 2018 20:27:26 +0200 Subject: [PATCH] Fix test method names. --- .../V1/Controllers/AboutControllerTest.php | 2 +- .../AvailableBudgetControllerTest.php | 68 +-- .../Api/V1/Controllers/BillControllerTest.php | 2 +- .../Controllers/PiggyBankControllerTest.php | 2 +- .../Api/V1/Controllers/RuleControllerTest.php | 133 +++--- .../Controllers/RuleGroupControllerTest.php | 2 +- .../Api/V1/Controllers/UserControllerTest.php | 2 +- .../Account/ShowControllerTest.php | 69 ++-- .../Admin/ConfigurationControllerTest.php | 2 +- .../Controllers/Admin/HomeControllerTest.php | 2 +- .../Controllers/Admin/LinkControllerTest.php | 2 +- .../Admin/UpdateControllerTest.php | 2 +- .../Controllers/AttachmentControllerTest.php | 2 +- .../Auth/ForgotPasswordControllerTest.php | 2 +- .../Auth/TwoFactorControllerTest.php | 2 +- .../Controllers/BillControllerTest.php | 2 +- .../Budget/AmountControllerTest.php | 87 ++-- .../Chart/AccountControllerTest.php | 2 +- .../Controllers/Chart/BillControllerTest.php | 4 +- .../Chart/BudgetControllerTest.php | 4 +- .../Chart/BudgetReportControllerTest.php | 2 +- .../Chart/CategoryControllerTest.php | 2 +- .../Chart/CategoryReportControllerTest.php | 2 +- .../Chart/ExpenseReportControllerTest.php | 2 +- .../Chart/PiggyBankControllerTest.php | 2 +- .../Chart/ReportControllerTest.php | 7 +- .../Chart/TagReportControllerTest.php | 2 +- .../Controllers/CurrencyControllerTest.php | 4 +- .../Controllers/DebugControllerTest.php | 2 +- .../Controllers/ExportControllerTest.php | 2 +- .../Controllers/HelpControllerTest.php | 2 +- .../Controllers/HomeControllerTest.php | 2 +- .../Import/CallbackControllerTest.php | 15 +- .../Import/IndexControllerTest.php | 2 +- .../Import/JobConfigurationControllerTest.php | 2 +- .../Import/JobStatusControllerTest.php | 2 +- .../Controllers/JavascriptControllerTest.php | 6 +- .../Json/AutoCompleteControllerTest.php | 2 +- .../Controllers/Json/BoxControllerTest.php | 64 +-- .../Json/ExchangeControllerTest.php | 30 +- .../Json/FrontpageControllerTest.php | 2 +- .../Controllers/Json/IntroControllerTest.php | 2 +- .../Json/ReconcileControllerTest.php | 2 +- .../Controllers/JsonControllerTest.php | 2 +- .../Controllers/NewUserControllerTest.php | 2 +- .../Controllers/PiggyBankControllerTest.php | 2 +- .../Popup/ReportControllerTest.php | 2 +- .../Controllers/PreferencesControllerTest.php | 2 +- .../Controllers/ProfileControllerTest.php | 2 +- .../Report/AccountControllerTest.php | 2 +- .../Report/BalanceControllerTest.php | 2 +- .../Report/BudgetControllerTest.php | 2 +- .../Report/CategoryControllerTest.php | 2 +- .../Report/ExpenseControllerTest.php | 2 +- .../Report/OperationsControllerTest.php | 2 +- .../Controllers/ReportControllerTest.php | 4 +- .../Controllers/Rule/CreateControllerTest.php | 2 +- .../Controllers/RuleGroupControllerTest.php | 2 +- .../Controllers/SearchControllerTest.php | 2 +- .../Feature/Controllers/TagControllerTest.php | 2 +- .../Transaction/BulkControllerTest.php | 2 +- .../Transaction/ConvertControllerTest.php | 4 +- .../Transaction/MassControllerTest.php | 2 +- .../Transaction/SingleControllerTest.php | 2 +- .../Transaction/SplitControllerTest.php | 2 +- .../Controllers/TransactionControllerTest.php | 2 +- tests/TestCase.php | 26 +- tests/Unit/Factory/RecurrenceFactoryTest.php | 388 +++++++++--------- tests/Unit/Factory/TransactionFactoryTest.php | 4 +- .../Factory/TransactionJournalFactoryTest.php | 2 +- .../Factory/TransactionTypeFactoryTest.php | 2 +- .../Chart/Basic/ChartJsGeneratorTest.php | 54 +-- .../Handlers/Events/AdminEventHandlerTest.php | 3 +- .../Attachments/AttachmentHelperTest.php | 4 +- tests/Unit/Helpers/Chart/MetaPieChartTest.php | 2 +- tests/Unit/Helpers/Help/HelpTest.php | 2 +- tests/Unit/Middleware/AuthenticateTest.php | 28 +- .../Middleware/AuthenticateTwoFactorTest.php | 28 +- tests/Unit/Middleware/IsAdminTest.php | 28 +- tests/Unit/Middleware/IsDemoUserTest.php | 28 +- tests/Unit/Middleware/IsSandstormUserTest.php | 28 +- tests/Unit/Middleware/RangeTest.php | 28 +- .../RedirectIf2FAAuthenticatedTest.php | 28 +- .../RedirectIfAuthenticatedTest.php | 28 +- tests/Unit/Middleware/SandstormTest.php | 28 +- .../Bunq/ChooseAccountsHandlerTest.php | 2 +- .../Triggers/CategoryIsTest.php | 3 +- .../Triggers/HasAnyBudgetTest.php | 1 - .../Triggers/HasAttachmentTest.php | 1 - .../Triggers/HasNoCategoryTest.php | 2 +- 90 files changed, 675 insertions(+), 676 deletions(-) diff --git a/tests/Api/V1/Controllers/AboutControllerTest.php b/tests/Api/V1/Controllers/AboutControllerTest.php index 38094b4c0e..2622b2d56c 100644 --- a/tests/Api/V1/Controllers/AboutControllerTest.php +++ b/tests/Api/V1/Controllers/AboutControllerTest.php @@ -35,7 +35,7 @@ class AboutControllerTest extends TestCase /** * Set up test */ - public function setUp() + public function setUp(): void { parent::setUp(); Passport::actingAs($this->user()); diff --git a/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php b/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php index 65bd2f7295..a37c12f2b7 100644 --- a/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php +++ b/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php @@ -148,6 +148,40 @@ class AvailableBudgetControllerTest extends TestCase $response->assertHeader('Content-Type', 'application/vnd.api+json'); } + /** + * Store new available budget without a valid currency. + * + * @covers \FireflyIII\Api\V1\Controllers\AvailableBudgetController + * @covers \FireflyIII\Api\V1\Requests\AvailableBudgetRequest + */ + public function testStoreNoCurrencyAtAll(): void + { + // mock stuff: + $repository = $this->mock(BudgetRepositoryInterface::class); + $currencyRepository = $this->mock(CurrencyRepositoryInterface::class); + + // mock calls: + $repository->shouldReceive('setUser')->once(); + $currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once(); + $currencyRepository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once(); + + // data to submit + $data = [ + 'currency_id' => '1', + 'currency_code' => 'EUR', + 'amount' => '100', + 'start_date' => '2018-01-01', + 'end_date' => '2018-01-31', + ]; + + + // test API + $response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']); + $response->assertStatus(500); + $response->assertSee('Could not find the indicated currency.'); // the amount + $response->assertHeader('Content-Type', 'application/json'); + } + /** * Store new available budget without a valid currency. * @@ -186,40 +220,6 @@ class AvailableBudgetControllerTest extends TestCase $response->assertSee($availableBudget->amount); // the amount $response->assertHeader('Content-Type', 'application/vnd.api+json'); } - /** - * Store new available budget without a valid currency. - * - * @covers \FireflyIII\Api\V1\Controllers\AvailableBudgetController - * @covers \FireflyIII\Api\V1\Requests\AvailableBudgetRequest - */ - public function testStoreNoCurrencyAtAll(): void - { - // mock stuff: - $repository = $this->mock(BudgetRepositoryInterface::class); - $currencyRepository = $this->mock(CurrencyRepositoryInterface::class); - - // mock calls: - $repository->shouldReceive('setUser')->once(); - $currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once(); - $currencyRepository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once(); - - // data to submit - $data = [ - 'currency_id' => '1', - 'currency_code' => 'EUR', - 'amount' => '100', - 'start_date' => '2018-01-01', - 'end_date' => '2018-01-31', - ]; - - - // test API - $response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']); - $response->assertStatus(500); - $response->assertSee('Could not find the indicated currency.'); // the amount - $response->assertHeader('Content-Type', 'application/json'); - } - /** * Update available budget. diff --git a/tests/Api/V1/Controllers/BillControllerTest.php b/tests/Api/V1/Controllers/BillControllerTest.php index 774037d255..01da6566f1 100644 --- a/tests/Api/V1/Controllers/BillControllerTest.php +++ b/tests/Api/V1/Controllers/BillControllerTest.php @@ -40,7 +40,7 @@ class BillControllerTest extends TestCase /** * */ - public function setUp() + public function setUp(): void { parent::setUp(); Passport::actingAs($this->user()); diff --git a/tests/Api/V1/Controllers/PiggyBankControllerTest.php b/tests/Api/V1/Controllers/PiggyBankControllerTest.php index 6b80771ee0..7c24398e80 100644 --- a/tests/Api/V1/Controllers/PiggyBankControllerTest.php +++ b/tests/Api/V1/Controllers/PiggyBankControllerTest.php @@ -239,7 +239,7 @@ class PiggyBankControllerTest extends TestCase $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first()); $data = [ - 'name' => 'new pigy bank ' . random_int(1, 10000), + 'name' => 'new pigy bank ' . random_int(1, 10000), 'account_id' => 1, 'target_amount' => '100', ]; diff --git a/tests/Api/V1/Controllers/RuleControllerTest.php b/tests/Api/V1/Controllers/RuleControllerTest.php index 86f195db9d..2f5dc9adee 100644 --- a/tests/Api/V1/Controllers/RuleControllerTest.php +++ b/tests/Api/V1/Controllers/RuleControllerTest.php @@ -142,6 +142,72 @@ class RuleControllerTest extends TestCase } + /** + * @covers \FireflyIII\Api\V1\Controllers\RuleController + * @covers \FireflyIII\Api\V1\Requests\RuleRequest + */ + public function testStoreNoActions(): void + { + $ruleRepos = $this->mock(RuleRepositoryInterface::class); + $ruleRepos->shouldReceive('setUser')->once(); + $rule = $this->user()->rules()->first(); + $data = [ + 'title' => 'Store new rule', + 'rule_group_id' => 1, + 'trigger' => 'store-journal', + 'strict' => 1, + 'stop_processing' => 1, + 'active' => 1, + 'rule_triggers' => [ + [ + 'name' => 'description_is', + 'value' => 'Hello', + 'stop_processing' => 1, + ], + ], + 'rule_actions' => [ + ], + ]; + + // test API + $response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']); + $response->assertStatus(422); + } + + /** + * @covers \FireflyIII\Api\V1\Controllers\RuleController + * @covers \FireflyIII\Api\V1\Requests\RuleRequest + */ + public function testStoreNoTriggers(): void + { + $ruleRepos = $this->mock(RuleRepositoryInterface::class); + $ruleRepos->shouldReceive('setUser')->once(); + $rule = $this->user()->rules()->first(); + $data = [ + 'title' => 'Store new rule', + 'rule_group_id' => 1, + 'trigger' => 'store-journal', + 'strict' => 1, + 'stop_processing' => 1, + 'active' => 1, + 'rule_triggers' => [ + ], + 'rule_actions' => [ + [ + 'name' => 'add_tag', + 'value' => 'A', + 'stop_processing' => 1, + ], + ], + ]; + + // test API + $response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']); + $response->assertStatus(422); + $response->assertSee(''); + + } + /** * @covers \FireflyIII\Api\V1\Controllers\RuleController * @covers \FireflyIII\Api\V1\Requests\RuleRequest @@ -183,71 +249,4 @@ class RuleControllerTest extends TestCase } - /** - * @covers \FireflyIII\Api\V1\Controllers\RuleController - * @covers \FireflyIII\Api\V1\Requests\RuleRequest - */ - public function testStoreNoTriggers(): void - { - $ruleRepos = $this->mock(RuleRepositoryInterface::class); - $ruleRepos->shouldReceive('setUser')->once(); - $rule = $this->user()->rules()->first(); - $data = [ - 'title' => 'Store new rule', - 'rule_group_id' => 1, - 'trigger' => 'store-journal', - 'strict' => 1, - 'stop_processing' => 1, - 'active' => 1, - 'rule_triggers' => [ - ], - 'rule_actions' => [ - [ - 'name' => 'add_tag', - 'value' => 'A', - 'stop_processing' => 1, - ], - ], - ]; - - // test API - $response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']); - $response->assertStatus(422); - $response->assertSee(''); - - } - - - /** - * @covers \FireflyIII\Api\V1\Controllers\RuleController - * @covers \FireflyIII\Api\V1\Requests\RuleRequest - */ - public function testStoreNoActions(): void - { - $ruleRepos = $this->mock(RuleRepositoryInterface::class); - $ruleRepos->shouldReceive('setUser')->once(); - $rule = $this->user()->rules()->first(); - $data = [ - 'title' => 'Store new rule', - 'rule_group_id' => 1, - 'trigger' => 'store-journal', - 'strict' => 1, - 'stop_processing' => 1, - 'active' => 1, - 'rule_triggers' => [ - [ - 'name' => 'description_is', - 'value' => 'Hello', - 'stop_processing' => 1, - ], - ], - 'rule_actions' => [ - ], - ]; - - // test API - $response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']); - $response->assertStatus(422); - } - } \ No newline at end of file diff --git a/tests/Api/V1/Controllers/RuleGroupControllerTest.php b/tests/Api/V1/Controllers/RuleGroupControllerTest.php index f77ea61029..c21b7785ab 100644 --- a/tests/Api/V1/Controllers/RuleGroupControllerTest.php +++ b/tests/Api/V1/Controllers/RuleGroupControllerTest.php @@ -90,7 +90,7 @@ class RuleGroupControllerTest extends TestCase public function testShow(): void { /** @var RuleGroup $ruleGroup */ - $ruleGroup = $this->user()->ruleGroups()->first(); + $ruleGroup = $this->user()->ruleGroups()->first(); $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class); $ruleGroupRepos->shouldReceive('setUser')->once(); diff --git a/tests/Api/V1/Controllers/UserControllerTest.php b/tests/Api/V1/Controllers/UserControllerTest.php index a54d8db930..489c205554 100644 --- a/tests/Api/V1/Controllers/UserControllerTest.php +++ b/tests/Api/V1/Controllers/UserControllerTest.php @@ -40,7 +40,7 @@ class UserControllerTest extends TestCase /** * */ - public function setUp() + public function setUp(): void { parent::setUp(); Passport::actingAs($this->user()); diff --git a/tests/Feature/Controllers/Account/ShowControllerTest.php b/tests/Feature/Controllers/Account/ShowControllerTest.php index 149069dcc5..238d030730 100644 --- a/tests/Feature/Controllers/Account/ShowControllerTest.php +++ b/tests/Feature/Controllers/Account/ShowControllerTest.php @@ -100,41 +100,6 @@ class ShowControllerTest extends TestCase $response->assertSee('