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('