From 288052905ee0fe448c430322d922f5cd516a0156 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 14 Mar 2021 10:41:17 +0100 Subject: [PATCH] Expand all test models. --- .../Models/RuleGroup/StoreRequest.php | 7 +- .../Models/TransactionLink/UpdateRequest.php | 19 ++- .../LinkType/LinkTypeRepository.php | 1 + app/Repositories/Rule/RuleRepository.php | 6 +- .../Rule/RuleRepositoryInterface.php | 2 +- .../RuleGroup/RuleGroupRepository.php | 74 +++++---- .../RuleGroupRepositoryInterface.php | 20 +-- app/Transformers/TagTransformer.php | 2 +- .../BudgetLimit/UpdateControllerTest.php | 4 +- .../ObjectGroup/UpdateControllerTest.php | 5 +- .../Models/PiggyBank/UpdateControllerTest.php | 2 +- .../Models/RuleGroup/StoreControllerTest.php | 138 +++++++++++++++ .../Models/RuleGroup/UpdateControllerTest.php | 122 ++++++++++++++ tests/Api/Models/Tag/StoreControllerTest.php | 140 ++++++++++++++++ tests/Api/Models/Tag/UpdateControllerTest.php | 124 ++++++++++++++ .../StoreControllerTest.php | 149 +++++++++++++++++ .../UpdateControllerTest.php | 136 +++++++++++++++ .../TransactionLink/StoreControllerTest.php | 143 ++++++++++++++++ .../TransactionLink/UpdateControllerTest.php | 129 ++++++++++++++ .../StoreControllerTest.php | 135 +++++++++++++++ .../UpdateControllerTest.php | 115 +++++++++++++ tests/Api/Webhook/StoreControllerTest.php | 157 ++++++++++++++++++ tests/Api/Webhook/UpdateControllerTest.php | 136 +++++++++++++++ tests/Traits/TestHelpers.php | 2 + 24 files changed, 1703 insertions(+), 65 deletions(-) create mode 100644 tests/Api/Models/RuleGroup/StoreControllerTest.php create mode 100644 tests/Api/Models/RuleGroup/UpdateControllerTest.php create mode 100644 tests/Api/Models/Tag/StoreControllerTest.php create mode 100644 tests/Api/Models/Tag/UpdateControllerTest.php create mode 100644 tests/Api/Models/TransactionCurrency/StoreControllerTest.php create mode 100644 tests/Api/Models/TransactionCurrency/UpdateControllerTest.php create mode 100644 tests/Api/Models/TransactionLink/StoreControllerTest.php create mode 100644 tests/Api/Models/TransactionLink/UpdateControllerTest.php create mode 100644 tests/Api/Models/TransactionLinkType/StoreControllerTest.php create mode 100644 tests/Api/Models/TransactionLinkType/UpdateControllerTest.php create mode 100644 tests/Api/Webhook/StoreControllerTest.php create mode 100644 tests/Api/Webhook/UpdateControllerTest.php diff --git a/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php b/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php index 1295286766..5f61b7257a 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\RuleGroup; -use FireflyIII\Models\RuleGroup; use FireflyIII\Rules\IsBoolean; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; @@ -46,15 +45,19 @@ class StoreRequest extends FormRequest public function getAll(): array { $active = true; - + $order = 31337; if (null !== $this->get('active')) { $active = $this->boolean('active'); } + if (null !== $this->get('order')) { + $order = $this->integer('order'); + } return [ 'title' => $this->string('title'), 'description' => $this->string('description'), 'active' => $active, + 'order' => $order, ]; } diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php index 1c20b128de..143c284056 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php @@ -28,7 +28,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; -use FireflyIII\User; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Validator; @@ -94,7 +93,7 @@ class UpdateRequest extends FormRequest { /** @var TransactionJournalLink $existing */ $existing = $this->route()->parameter('journalLink'); - $data = $validator->getData(); + $data = $validator->getData(); /** @var LinkTypeRepositoryInterface $repository */ $repository = app(LinkTypeRepositoryInterface::class); $repository->setUser(auth()->user()); @@ -107,7 +106,13 @@ class UpdateRequest extends FormRequest $outwardId = $data['outward_id'] ?? $existing->destination_id; $inward = $journalRepos->findNull((int)$inwardId); $outward = $journalRepos->findNull((int)$outwardId); - if($inward->id === $outward->id) { + if (null === $inward) { + $inward = $existing->source; + } + if (null === $outward) { + $outward = $existing->destination; + } + if ($inward->id === $outward->id) { $validator->errors()->add('inward_id', 'Inward ID must be different from outward ID.'); $validator->errors()->add('outward_id', 'Inward ID must be different from outward ID.'); } @@ -115,14 +120,14 @@ class UpdateRequest extends FormRequest if (null === $inward) { $validator->errors()->add('inward_id', 'This is not a valid inward journal.'); } - if(null === $outward) { + if (null === $outward) { $validator->errors()->add('inward_id', 'This is not a valid outward journal.'); } - $inDB =$repository->findSpecificLink($existing->linkType, $inward, $outward); - if(null === $inDB) { + $inDB = $repository->findSpecificLink($existing->linkType, $inward, $outward); + if (null === $inDB) { return; } - if($inDB->id !== $existing->id) { + if ($inDB->id !== $existing->id) { $validator->errors()->add('outward_id', 'Already have a link between inward and outward.'); $validator->errors()->add('inward_id', 'Already have a link between inward and outward.'); } diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index a9f3866b13..6602e06d99 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -107,6 +107,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface */ public function findLink(TransactionJournal $one, TransactionJournal $two): bool { + Log::debug(sprintf('Now in findLink(%d, %d)', $one->id, $two->id)); $count = TransactionJournalLink::whereDestinationId($one->id)->whereSourceId($two->id)->count(); $opposingCount = TransactionJournalLink::whereDestinationId($two->id)->whereSourceId($one->id)->count(); diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index d57760baf9..cf0b6409bb 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -274,7 +274,7 @@ class RuleRepository implements RuleRepositoryInterface ++$rule->order; $rule->save(); - $this->resetRulesInGroupOrder($rule->ruleGroup); + $this->resetRuleOrder($rule->ruleGroup); return true; } @@ -311,7 +311,7 @@ class RuleRepository implements RuleRepositoryInterface --$rule->order; $rule->save(); - $this->resetRulesInGroupOrder($rule->ruleGroup); + $this->resetRuleOrder($rule->ruleGroup); return true; } @@ -365,7 +365,7 @@ class RuleRepository implements RuleRepositoryInterface * * @return bool */ - public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool + public function resetRuleOrder(RuleGroup $ruleGroup): bool { $ruleGroup->rules()->withTrashed()->whereNotNull('deleted_at')->update(['order' => 0]); diff --git a/app/Repositories/Rule/RuleRepositoryInterface.php b/app/Repositories/Rule/RuleRepositoryInterface.php index 397ff8cd5f..f9e7650108 100644 --- a/app/Repositories/Rule/RuleRepositoryInterface.php +++ b/app/Repositories/Rule/RuleRepositoryInterface.php @@ -167,7 +167,7 @@ interface RuleRepositoryInterface * * @return bool */ - public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool; + public function resetRuleOrder(RuleGroup $ruleGroup): bool; /** * @param string $query diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index 8b18dcc301..e8031a3923 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -89,9 +89,9 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface $ruleGroup->delete(); - $this->resetRuleGroupOrder(); + $this->resetOrder(); if (null !== $moveTo) { - $this->resetRulesInGroupOrder($moveTo); + $this->resetRuleOrder($moveTo); } return true; @@ -324,21 +324,25 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface /** * @return bool */ - public function resetRuleGroupOrder(): bool + public function resetOrder(): bool { - $this->user->ruleGroups()->whereNotNull('deleted_at')->update(['order' => 0]); + $this->user->ruleGroups()->whereNotNull('deleted_at'); $set = $this->user ->ruleGroups() - ->orderBy('order', 'ASC')->get(); + ->orderBy('order', 'ASC') + ->orderBy('title', 'DESC') + ->get(); $count = 1; /** @var RuleGroup $entry */ foreach ($set as $entry) { - $entry->order = $count; - $entry->save(); + if ($entry->order !== $count) { + $entry->order = $count; + $entry->save(); + } // also update rules in group. - $this->resetRulesInGroupOrder($entry); + $this->resetRuleOrder($entry); ++$count; } @@ -351,19 +355,21 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface * * @return bool */ - public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool + public function resetRuleOrder(RuleGroup $ruleGroup): bool { - $ruleGroup->rules()->whereNotNull('deleted_at')->update(['order' => 0]); - $set = $ruleGroup->rules() ->orderBy('order', 'ASC') + ->orderBy('title', 'DESC') ->orderBy('updated_at', 'DESC') - ->get(); + ->get(['rules.*']); $count = 1; /** @var Rule $entry */ foreach ($set as $entry) { - $entry->order = $count; - $entry->save(); + if ($entry->order !== $count) { + $entry->order = $count; + $entry->save(); + } + ++$count; } @@ -400,19 +406,18 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface */ public function store(array $data): RuleGroup { - $order = $this->getHighestOrderRuleGroup(); - $newRuleGroup = new RuleGroup( [ 'user_id' => $this->user->id, 'title' => $data['title'], 'description' => $data['description'], - 'order' => $order + 1, + 'order' => 31337, 'active' => $data['active'], ] ); $newRuleGroup->save(); - $this->resetRuleGroupOrder(); + $this->resetOrder(); + $this->setOrder($newRuleGroup, $data['order']); return $newRuleGroup; } @@ -437,11 +442,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface } // order if (array_key_exists('order', $data) && $ruleGroup->order !== $data['order']) { - $this->correctRuleGroupOrder(); - $max = $this->maxOrder(); - // TODO also for bills and accounts: - $data['order'] = $data['order'] > $max ? $max : $data['order']; - $ruleGroup = $this->updateOrder($ruleGroup, $ruleGroup->order, $data['order']); + $this->resetOrder(); + $this->setOrder($ruleGroup, (int)$data['order']); } $ruleGroup->save(); @@ -449,26 +451,30 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface return $ruleGroup; } + /** * @inheritDoc */ - public function updateOrder(RuleGroup $ruleGroup, int $oldOrder, int $newOrder): RuleGroup + public function setOrder(RuleGroup $ruleGroup, int $newOrder): void { + $oldOrder = (int)$ruleGroup->order; + if ($newOrder > $oldOrder) { - $this->user->ruleGroups()->where('order', '<=', $newOrder)->where('order', '>', $oldOrder) + $this->user->ruleGroups()->where('rule_groups.order', '<=', $newOrder)->where('rule_groups.order', '>', $oldOrder) ->where('rule_groups.id', '!=', $ruleGroup->id) - ->decrement('rule_groups.order', 1); - $ruleGroup->order = $newOrder; - $ruleGroup->save(); - } - if ($newOrder < $oldOrder) { - $this->user->ruleGroups()->where('order', '>=', $newOrder)->where('order', '<', $oldOrder) - ->where('rule_groups.id', '!=', $ruleGroup->id) - ->increment('rule_groups.order', 1); + ->decrement('order', 1); $ruleGroup->order = $newOrder; + Log::debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder)); $ruleGroup->save(); + + return; } - return $ruleGroup; + $this->user->ruleGroups()->where('rule_groups.order', '>=', $newOrder)->where('rule_groups.order', '<', $oldOrder) + ->where('rule_groups.id', '!=', $ruleGroup->id) + ->increment('order', 1); + $ruleGroup->order = $newOrder; + Log::debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder)); + $ruleGroup->save(); } } diff --git a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php index 55e40f103b..84f8fbc436 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php +++ b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php @@ -145,14 +145,20 @@ interface RuleGroupRepositoryInterface /** * @return bool */ - public function resetRuleGroupOrder(): bool; + public function resetOrder(): bool; /** * @param RuleGroup $ruleGroup * * @return bool */ - public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool; + public function resetRuleOrder(RuleGroup $ruleGroup): bool; + + /** + * @param RuleGroup $ruleGroup + * @param int $newOrder + */ + public function setOrder(RuleGroup $ruleGroup, int $newOrder): void; /** * @param string $query @@ -181,14 +187,4 @@ interface RuleGroupRepositoryInterface * @return RuleGroup */ public function update(RuleGroup $ruleGroup, array $data): RuleGroup; - - /** - * - * @param RuleGroup $ruleGroup - * @param int $oldOrder - * @param int $newOrder - * - * @return RuleGroup - */ - public function updateOrder(RuleGroup $ruleGroup, int $oldOrder, int $newOrder): RuleGroup; } diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.php index cf5ff6af2f..8f5c6114e3 100644 --- a/app/Transformers/TagTransformer.php +++ b/app/Transformers/TagTransformer.php @@ -53,7 +53,7 @@ class TagTransformer extends AbstractTransformer if (null !== $location) { $latitude = $location->latitude; $longitude = $location->longitude; - $zoomLevel = $location->zoom_level; + $zoomLevel = (int)$location->zoom_level; } return [ 'id' => (int)$tag->id, diff --git a/tests/Api/Models/BudgetLimit/UpdateControllerTest.php b/tests/Api/Models/BudgetLimit/UpdateControllerTest.php index 546352ef73..8b8bf63f8c 100644 --- a/tests/Api/Models/BudgetLimit/UpdateControllerTest.php +++ b/tests/Api/Models/BudgetLimit/UpdateControllerTest.php @@ -121,7 +121,7 @@ class UpdateControllerTest extends TestCase 'fields' => [ 'start' => ['test_value' => $faker->dateTimeBetween('-2 year', '-1 year')->format('Y-m-d')], ], - 'extra_ignore' => [], + 'extra_ignore' => ['spent'], ], 'end' => [ 'id' => 1, @@ -129,7 +129,7 @@ class UpdateControllerTest extends TestCase 'fields' => [ 'end' => ['test_value' => $faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d')], ], - 'extra_ignore' => [], + 'extra_ignore' => ['spent'], ], 'amount' => [ 'id' => 1, diff --git a/tests/Api/Models/ObjectGroup/UpdateControllerTest.php b/tests/Api/Models/ObjectGroup/UpdateControllerTest.php index 270821f233..dc78be105e 100644 --- a/tests/Api/Models/ObjectGroup/UpdateControllerTest.php +++ b/tests/Api/Models/ObjectGroup/UpdateControllerTest.php @@ -86,19 +86,20 @@ class UpdateControllerTest extends TestCase $faker = Factory::create(); $set = [ 'title' => [ - 'id' => 1, + 'id' => 3, 'fields' => [ 'title' => ['test_value' => $faker->uuid], ], 'extra_ignore' => [], ], 'order' => [ - 'id' => 1, + 'id' => 3, 'fields' => [ 'order' => ['test_value' => $faker->numberBetween(1, 2)], ], 'extra_ignore' => [], ], + ]; return $set; diff --git a/tests/Api/Models/PiggyBank/UpdateControllerTest.php b/tests/Api/Models/PiggyBank/UpdateControllerTest.php index e4a9fbb38d..e81e377060 100644 --- a/tests/Api/Models/PiggyBank/UpdateControllerTest.php +++ b/tests/Api/Models/PiggyBank/UpdateControllerTest.php @@ -99,7 +99,7 @@ class UpdateControllerTest extends TestCase 'fields' => [ 'account_id' => ['test_value' => (string)$faker->numberBetween(1, 3)], ], - 'extra_ignore' => ['account_name'], + 'extra_ignore' => ['account_name','currency_id','currency_code'], ], 'target_amount' => [ 'id' => 1, diff --git a/tests/Api/Models/RuleGroup/StoreControllerTest.php b/tests/Api/Models/RuleGroup/StoreControllerTest.php new file mode 100644 index 0000000000..7537c26117 --- /dev/null +++ b/tests/Api/Models/RuleGroup/StoreControllerTest.php @@ -0,0 +1,138 @@ +. + */ + +namespace Tests\Api\Models\RuleGroup; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class StoreControllerTest + */ +class StoreControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @param array $submission + * + * emptyDataProvider / storeDataProvider + * + * @dataProvider storeDataProvider + */ + public function testStore(array $submission): void + { + if ([] === $submission) { + $this->markTestSkipped('Empty data provider'); + } + $route = 'api.v1.rule_groups.store'; + $this->storeAndCompare($route, $submission); + } + + /** + * @return array + */ + public function emptyDataProvider(): array + { + return [[[]]]; + + } + + /** + * @return array + */ + public function storeDataProvider(): array + { + $minimalSets = $this->minimalSets(); + $optionalSets = $this->optionalSets(); + $regenConfig = [ + 'title' => function () { + $faker = Factory::create(); + + return $faker->uuid; + }, + ]; + + return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); + } + + /** + * @return array + */ + private function minimalSets(): array + { + $faker = Factory::create(); + + return [ + 'default_group' => [ + 'parameters' => [], + 'fields' => [ + 'title' => $faker->uuid, + ], + ], + ]; + } + + + /** + * @return \array[][] + */ + private function optionalSets(): array + { + $faker = Factory::create(); + + return [ + 'description' => [ + 'fields' => [ + 'description' => $faker->uuid, + ], + ], + 'order' => [ + 'fields' => [ + 'order' => $faker->numberBetween(1, 5), + ], + ], + 'active' => [ + 'fields' => [ + 'active' => $faker->boolean, + ], + ], + ]; + } + +} \ No newline at end of file diff --git a/tests/Api/Models/RuleGroup/UpdateControllerTest.php b/tests/Api/Models/RuleGroup/UpdateControllerTest.php new file mode 100644 index 0000000000..dff0c96473 --- /dev/null +++ b/tests/Api/Models/RuleGroup/UpdateControllerTest.php @@ -0,0 +1,122 @@ +. + */ + +namespace Tests\Api\Models\RuleGroup; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class UpdateControllerTest + */ +class UpdateControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @dataProvider updateDataProvider + */ + public function testUpdate(array $submission): void + { + $ignore = [ + 'created_at', + 'updated_at', + ]; + $route = route('api.v1.rule_groups.update', [$submission['id']]); + + $this->updateAndCompare($route, $submission, $ignore); + } + + + /** + * @return array + */ + public function updateDataProvider(): array + { + $submissions = []; + $all = $this->updateDataSet(); + foreach ($all as $name => $data) { + $submissions[] = [$data]; + } + + return $submissions; + } + + + /** + * @return array + */ + public function updateDataSet(): array + { + $faker = Factory::create(); + $set = [ + 'title' => [ + 'id' => 1, + 'fields' => [ + 'title' => ['test_value' => $faker->uuid], + ], + 'extra_ignore' => [], + ], + 'description' => [ + 'id' => 1, + 'fields' => [ + 'description' => ['test_value' => join(' ', $faker->words(5))], + ], + 'extra_ignore' => [], + ], + 'order' => [ + 'id' => 1, + 'fields' => [ + 'order' => ['test_value' => $faker->numberBetween(1, 5)], + ], + 'extra_ignore' => [], + ], + 'active' => [ + 'id' => 1, + 'fields' => [ + 'active' => ['test_value' => $faker->boolean], + ], + 'extra_ignore' => [], + ], + ]; + + return $set; + } + + +} \ No newline at end of file diff --git a/tests/Api/Models/Tag/StoreControllerTest.php b/tests/Api/Models/Tag/StoreControllerTest.php new file mode 100644 index 0000000000..d860f0d84d --- /dev/null +++ b/tests/Api/Models/Tag/StoreControllerTest.php @@ -0,0 +1,140 @@ +. + */ + +namespace Tests\Api\Models\Tag; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class StoreControllerTest + */ +class StoreControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @param array $submission + * + * emptyDataProvider / storeDataProvider + * + * @dataProvider storeDataProvider + */ + public function testStore(array $submission): void + { + if ([] === $submission) { + $this->markTestSkipped('Empty data provider'); + } + $route = 'api.v1.tags.store'; + $this->storeAndCompare($route, $submission); + } + + /** + * @return array + */ + public function emptyDataProvider(): array + { + return [[[]]]; + + } + + /** + * @return array + */ + public function storeDataProvider(): array + { + $minimalSets = $this->minimalSets(); + $optionalSets = $this->optionalSets(); + $regenConfig = [ + 'tag' => function () { + $faker = Factory::create(); + + return $faker->uuid; + }, + ]; + + return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); + } + + /** + * @return array + */ + private function minimalSets(): array + { + $faker = Factory::create(); + + return [ + 'default_tag' => [ + 'parameters' => [], + 'fields' => [ + 'tag' => $faker->uuid, + ], + ], + ]; + } + + + /** + * @return \array[][] + */ + private function optionalSets(): array + { + $faker = Factory::create(); + + return [ + 'date' => [ + 'fields' => [ + 'date' => $faker->date('Y-m-d'), + ], + ], + 'description' => [ + 'fields' => [ + 'description' => join(' ', $faker->words(4)), + ], + ], + 'location' => [ + 'fields' => [ + 'longitude' => $faker->longitude, + 'latitude' => $faker->latitude, + 'zoom_level' => $faker->numberBetween(1, 6), + ], + ], + ]; + } + +} \ No newline at end of file diff --git a/tests/Api/Models/Tag/UpdateControllerTest.php b/tests/Api/Models/Tag/UpdateControllerTest.php new file mode 100644 index 0000000000..f7f03ca40e --- /dev/null +++ b/tests/Api/Models/Tag/UpdateControllerTest.php @@ -0,0 +1,124 @@ +. + */ + +namespace Tests\Api\Models\Tag; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class UpdateControllerTest + */ +class UpdateControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @dataProvider updateDataProvider + */ + public function testUpdate(array $submission): void + { + $ignore = [ + 'created_at', + 'updated_at', + ]; + $route = route('api.v1.tags.update', [$submission['id']]); + + $this->updateAndCompare($route, $submission, $ignore); + } + + + /** + * @return array + */ + public function updateDataProvider(): array + { + $submissions = []; + $all = $this->updateDataSet(); + foreach ($all as $name => $data) { + $submissions[] = [$data]; + } + + return $submissions; + } + + + /** + * @return array + */ + public function updateDataSet(): array + { + $faker = Factory::create(); + $set = [ + 'tag' => [ + 'id' => 1, + 'fields' => [ + 'tag' => ['test_value' => $faker->uuid], + ], + 'extra_ignore' => [], + ], + 'date' => [ + 'id' => 1, + 'fields' => [ + 'date' => ['test_value' => $faker->date()], + ], + 'extra_ignore' => [], + ], + 'description' => [ + 'id' => 1, + 'fields' => [ + 'description' => ['test_value' => join(' ', $faker->words(5))], + ], + 'extra_ignore' => [], + ], + 'location' => [ + 'id' => 1, + 'fields' => [ + 'longitude' => ['test_value' => $faker->longitude], + 'latitude' => ['test_value' => $faker->latitude], + 'zoom_level' => ['test_value' => $faker->numberBetween(1, 6)], + ], + 'extra_ignore' => [], + ], + ]; + + return $set; + } + + +} \ No newline at end of file diff --git a/tests/Api/Models/TransactionCurrency/StoreControllerTest.php b/tests/Api/Models/TransactionCurrency/StoreControllerTest.php new file mode 100644 index 0000000000..cc51fb34a6 --- /dev/null +++ b/tests/Api/Models/TransactionCurrency/StoreControllerTest.php @@ -0,0 +1,149 @@ +. + */ + +namespace Tests\Api\Models\TransactionCurrency; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class StoreControllerTest + */ +class StoreControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @param array $submission + * + * emptyDataProvider / storeDataProvider + * + * @dataProvider storeDataProvider + */ + public function testStore(array $submission): void + { + if ([] === $submission) { + $this->markTestSkipped('Empty data provider'); + } + $route = 'api.v1.currencies.store'; + $this->storeAndCompare($route, $submission); + } + + /** + * @return array + */ + public function emptyDataProvider(): array + { + return [[[]]]; + + } + + /** + * @return array + */ + public function storeDataProvider(): array + { + $minimalSets = $this->minimalSets(); + $optionalSets = $this->optionalSets(); + $regenConfig = [ + 'code' => function () { + $faker = Factory::create(); + + return substr($faker->uuid, 0, 3); + }, + 'name' => function () { + $faker = Factory::create(); + + return $faker->uuid; + }, + 'symbol' => function () { + $faker = Factory::create(); + return $faker->randomAscii.$faker->randomAscii; + }, + ]; + + return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); + } + + /** + * @return array + */ + private function minimalSets(): array + { + $faker = Factory::create(); + + return [ + 'default_currency' => [ + 'parameters' => [], + 'fields' => [ + 'code' => substr($faker->uuid, 0, 3), + 'name' => $faker->uuid, + 'symbol' => $faker->randomAscii.$faker->randomAscii, + ], + ], + ]; + } + + + /** + * @return \array[][] + */ + private function optionalSets(): array + { + $faker = Factory::create(); + + return [ + 'enabled' => [ + 'fields' => [ + 'enabled' => $faker->boolean, + ], + ], + 'default' => [ + 'fields' => [ + 'default' => $faker->boolean, + ], + ], + 'decimal_places' => [ + 'fields' => [ + 'decimal_places' => $faker->numberBetween(1, 6), + ], + ], + ]; + } + +} \ No newline at end of file diff --git a/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php b/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php new file mode 100644 index 0000000000..a970725f0f --- /dev/null +++ b/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php @@ -0,0 +1,136 @@ +. + */ + +namespace Tests\Api\Models\TransactionCurrency; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class UpdateControllerTest + */ +class UpdateControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @dataProvider updateDataProvider + */ + public function testUpdate(array $submission): void + { + $ignore = [ + 'created_at', + 'updated_at', + ]; + $route = route('api.v1.currencies.update', [$submission['id']]); + + $this->updateAndCompare($route, $submission, $ignore); + } + + + /** + * @return array + */ + public function updateDataProvider(): array + { + $submissions = []; + $all = $this->updateDataSet(); + foreach ($all as $name => $data) { + $submissions[] = [$data]; + } + + return $submissions; + } + + + /** + * @return array + */ + public function updateDataSet(): array + { + $faker = Factory::create(); + $set = [ + 'name' => [ + 'id' => 'INR', + 'fields' => [ + 'name' => ['test_value' => $faker->uuid], + ], + 'extra_ignore' => [], + ], + 'code' => [ + 'id' => 'INR', + 'fields' => [ + 'code' => ['test_value' => substr($faker->uuid, 0, 3)], + ], + 'extra_ignore' => [], + ], + 'symbol' => [ + 'id' => 'RUB', + 'fields' => [ + 'description' => ['test_value' => $faker->randomAscii.$faker->randomAscii], + ], + 'extra_ignore' => [], + ], + 'decimal_places' => [ + 'id' => 'ETH', + 'fields' => [ + 'decimal_places' => ['test_value' => $faker->numberBetween(1, 6)], + ], + 'extra_ignore' => [], + ], + 'enabled' => [ + 'id' => 'ETH', + 'fields' => [ + 'enabled' => ['test_value' => $faker->boolean], + ], + 'extra_ignore' => [], + ], + 'default' => [ + 'id' => 'XBT', + 'fields' => [ + 'default' => ['test_value' => $faker->boolean], + ], + 'extra_ignore' => [], + ], + ]; + + return $set; + } + + +} \ No newline at end of file diff --git a/tests/Api/Models/TransactionLink/StoreControllerTest.php b/tests/Api/Models/TransactionLink/StoreControllerTest.php new file mode 100644 index 0000000000..a1547baf6d --- /dev/null +++ b/tests/Api/Models/TransactionLink/StoreControllerTest.php @@ -0,0 +1,143 @@ +. + */ + +namespace Tests\Api\Models\TransactionLink; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class StoreControllerTest + */ +class StoreControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @param array $submission + * + * emptyDataProvider / storeDataProvider + * + * @dataProvider storeDataProvider + */ + public function testStore(array $submission): void + { + if ([] === $submission) { + $this->markTestSkipped('Empty data provider'); + } + $route = 'api.v1.transaction_links.store'; + $this->storeAndCompare($route, $submission); + } + + /** + * @return array + */ + public function emptyDataProvider(): array + { + return [[[]]]; + + } + + /** + * @return array + */ + public function storeDataProvider(): array + { + $minimalSets = $this->minimalSets(); + $optionalSets = $this->optionalSets(); + $regenConfig = [ + 'inward_id' => function () { + $faker = Factory::create(); + + return (string)$faker->numberBetween(1, 10); + }, + 'outward_id' => function () { + $faker = Factory::create(); + + return (string)$faker->numberBetween(11, 20); + }, + ]; + + return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); + } + + /** + * @return array + */ + private function minimalSets(): array + { + $faker = Factory::create(); + + return [ + 'default_link_id' => [ + 'parameters' => [], + 'fields' => [ + 'link_type_id' => (string)$faker->numberBetween(1, 4), + 'inward_id' => (string)$faker->numberBetween(1, 10), + 'outward_id' => (string)$faker->numberBetween(11, 20), + ], + ], + 'default_link_name' => [ + 'parameters' => [], + 'fields' => [ + 'link_type_name' => 'Related', + 'inward_id' => (string)$faker->numberBetween(1, 10), + 'outward_id' => (string)$faker->numberBetween(11, 20), + ], + ], + ]; + } + + + /** + * @return \array[][] + */ + private function optionalSets(): array + { + $faker = Factory::create(); + + return [ + 'notes' => [ + 'fields' => [ + 'notes' => join(' ', $faker->words(5)), + ], + ], + ]; + } + +} \ No newline at end of file diff --git a/tests/Api/Models/TransactionLink/UpdateControllerTest.php b/tests/Api/Models/TransactionLink/UpdateControllerTest.php new file mode 100644 index 0000000000..e049b1178e --- /dev/null +++ b/tests/Api/Models/TransactionLink/UpdateControllerTest.php @@ -0,0 +1,129 @@ +. + */ + +namespace Tests\Api\Models\TransactionLink; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class UpdateControllerTest + */ +class UpdateControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @dataProvider updateDataProvider + */ + public function testUpdate(array $submission): void + { + $ignore = [ + 'created_at', + 'updated_at', + ]; + $route = route('api.v1.transaction_links.update', [$submission['id']]); + + $this->updateAndCompare($route, $submission, $ignore); + } + + + /** + * @return array + */ + public function updateDataProvider(): array + { + $submissions = []; + $all = $this->updateDataSet(); + foreach ($all as $name => $data) { + $submissions[] = [$data]; + } + + return $submissions; + } + + + /** + * @return array + */ + public function updateDataSet(): array + { + $faker = Factory::create(); + $set = [ + 'link_type_id' => [ + 'id' => 1, + 'fields' => [ + 'link_type_id' => ['test_value' => (string)$faker->numberBetween(1,3)], + ], + 'extra_ignore' => ['link_type_name'], + ], + 'link_type_name' => [ + 'id' => 1, + 'fields' => [ + 'link_type_name' => ['test_value' => 'Refund'], + ], + 'extra_ignore' => ['link_type_id'], + ], + 'inward_id' => [ + 'id' => 1, + 'fields' => [ + 'inward_id' => ['test_value' => (string)$faker->numberBetween(11,20)], + ], + 'extra_ignore' => [], + ], + 'outward_id' => [ + 'id' => 1, + 'fields' => [ + 'outward_id' => ['test_value' => (string)$faker->numberBetween(11, 30)], + ], + 'extra_ignore' => [], + ], + 'notes' => [ + 'id' => 1, + 'fields' => [ + 'notes' => ['test_value' => join(' ', $faker->words(5))], + ], + 'extra_ignore' => [], + ], + ]; + + return $set; + } + + +} \ No newline at end of file diff --git a/tests/Api/Models/TransactionLinkType/StoreControllerTest.php b/tests/Api/Models/TransactionLinkType/StoreControllerTest.php new file mode 100644 index 0000000000..e7b2535060 --- /dev/null +++ b/tests/Api/Models/TransactionLinkType/StoreControllerTest.php @@ -0,0 +1,135 @@ +. + */ + +namespace Tests\Api\Models\TransactionLinkType; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class StoreControllerTest + */ +class StoreControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @param array $submission + * + * emptyDataProvider / storeDataProvider + * + * @dataProvider storeDataProvider + */ + public function testStore(array $submission): void + { + if ([] === $submission) { + $this->markTestSkipped('Empty data provider'); + } + $route = 'api.v1.link_types.store'; + $this->storeAndCompare($route, $submission); + } + + /** + * @return array + */ + public function emptyDataProvider(): array + { + return [[[]]]; + + } + + /** + * @return array + */ + public function storeDataProvider(): array + { + $minimalSets = $this->minimalSets(); + $optionalSets = $this->optionalSets(); + $regenConfig = [ + 'name' => function () { + $faker = Factory::create(); + + return $faker->uuid; + }, + 'inward' => function () { + $faker = Factory::create(); + + return $faker->uuid; + }, + 'outward' => function () { + $faker = Factory::create(); + + return $faker->uuid; + }, + ]; + + return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); + } + + /** + * @return array + */ + private function minimalSets(): array + { + $faker = Factory::create(); + + return [ + 'default_link_type' => [ + 'parameters' => [], + 'fields' => [ + 'name' => $faker->uuid, + 'inward' => $faker->uuid, + 'outward' => $faker->uuid, + ], + ], + + ]; + } + + + /** + * @return \array[][] + */ + private function optionalSets(): array + { + return [ + + ]; + } + +} \ No newline at end of file diff --git a/tests/Api/Models/TransactionLinkType/UpdateControllerTest.php b/tests/Api/Models/TransactionLinkType/UpdateControllerTest.php new file mode 100644 index 0000000000..4390f4a3cf --- /dev/null +++ b/tests/Api/Models/TransactionLinkType/UpdateControllerTest.php @@ -0,0 +1,115 @@ +. + */ + +namespace Tests\Api\Models\TransactionLinkType; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class UpdateControllerTest + */ +class UpdateControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @dataProvider updateDataProvider + */ + public function testUpdate(array $submission): void + { + $ignore = [ + 'created_at', + 'updated_at', + ]; + $route = route('api.v1.link_types.update', [$submission['id']]); + + $this->updateAndCompare($route, $submission, $ignore); + } + + + /** + * @return array + */ + public function updateDataProvider(): array + { + $submissions = []; + $all = $this->updateDataSet(); + foreach ($all as $name => $data) { + $submissions[] = [$data]; + } + + return $submissions; + } + + + /** + * @return array + */ + public function updateDataSet(): array + { + $faker = Factory::create(); + $set = [ + 'name' => [ + 'id' => 5, + 'fields' => [ + 'name' => ['test_value' => $faker->uuid], + ], + 'extra_ignore' => [], + ], + 'inward' => [ + 'id' => 5, + 'fields' => [ + 'inward' => ['test_value' => $faker->uuid], + ], + 'extra_ignore' => [], + ], + 'outward' => [ + 'id' => 5, + 'fields' => [ + 'outward' => ['test_value' => $faker->uuid], + ], + 'extra_ignore' => [], + ], + ]; + + return $set; + } + + +} \ No newline at end of file diff --git a/tests/Api/Webhook/StoreControllerTest.php b/tests/Api/Webhook/StoreControllerTest.php new file mode 100644 index 0000000000..ea6b53f858 --- /dev/null +++ b/tests/Api/Webhook/StoreControllerTest.php @@ -0,0 +1,157 @@ +. + */ + +namespace Tests\Api\Webhook; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class StoreControllerTest + */ +class StoreControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @param array $submission + * + * emptyDataProvider / storeDataProvider + * + * @dataProvider storeDataProvider + */ + public function testStore(array $submission): void + { + if ([] === $submission) { + $this->markTestSkipped('Empty data provider'); + } + $route = 'api.v1.webhooks.store'; + $this->storeAndCompare($route, $submission); + } + + /** + * @return array + */ + public function emptyDataProvider(): array + { + return [[[]]]; + + } + + /** + * @return array + */ + public function storeDataProvider(): array + { + $minimalSets = $this->minimalSets(); + $optionalSets = $this->optionalSets(); + $regenConfig = [ + 'title' => function () { + $faker = Factory::create(); + + return $faker->uuid; + }, + 'url' => function () { + $faker = Factory::create(); + + return str_replace(['http://'], 'https://', $faker->url); + }, + 'trigger' => function () { + $faker = Factory::create(); + + return $faker->randomElement(['TRIGGER_STORE_TRANSACTION', 'TRIGGER_UPDATE_TRANSACTION', 'TRIGGER_DESTROY_TRANSACTION']); + }, + 'response' => function () { + $faker = Factory::create(); + + return $faker->randomElement(['RESPONSE_TRANSACTIONS', 'RESPONSE_ACCOUNTS', 'RESPONSE_NONE']); + }, + 'delivery' => function () { + $faker = Factory::create(); + + return $faker->randomElement(['DELIVERY_JSON']); + }, + ]; + + return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); + } + + /** + * @return array + */ + private function minimalSets(): array + { + $faker = Factory::create(); + // - title + // - trigger + // - response + // - delivery + // - url + + return [ + 'default_webhook' => [ + 'parameters' => [], + 'fields' => [ + 'title' => $faker->uuid, + 'trigger' => $faker->randomElement(['TRIGGER_STORE_TRANSACTION', 'TRIGGER_UPDATE_TRANSACTION', 'TRIGGER_DESTROY_TRANSACTION']), + 'response' => $faker->randomElement(['RESPONSE_TRANSACTIONS', 'RESPONSE_ACCOUNTS', 'RESPONSE_NONE']), + 'delivery' => $faker->randomElement(['DELIVERY_JSON']), + 'url' => str_replace(['http://'], 'https://', $faker->url), + ], + ], + + ]; + } + + + /** + * @return \array[][] + */ + private function optionalSets(): array + { + $faker = Factory::create(); + return [ + 'active' => [ + 'fields' => [ + 'active' => $faker->boolean, + ], + ], + ]; + } + +} \ No newline at end of file diff --git a/tests/Api/Webhook/UpdateControllerTest.php b/tests/Api/Webhook/UpdateControllerTest.php new file mode 100644 index 0000000000..3ae221e3cb --- /dev/null +++ b/tests/Api/Webhook/UpdateControllerTest.php @@ -0,0 +1,136 @@ +. + */ + +namespace Tests\Api\Webhook; + + +use Faker\Factory; +use Laravel\Passport\Passport; +use Log; +use Tests\TestCase; +use Tests\Traits\CollectsValues; +use Tests\Traits\RandomValues; +use Tests\Traits\TestHelpers; + +/** + * Class UpdateControllerTest + */ +class UpdateControllerTest extends TestCase +{ + use RandomValues, TestHelpers, CollectsValues; + + /** + * + */ + public function setUp(): void + { + parent::setUp(); + Passport::actingAs($this->user()); + Log::info(sprintf('Now in %s.', get_class($this))); + } + + + /** + * @dataProvider updateDataProvider + */ + public function testUpdate(array $submission): void + { + $ignore = [ + 'created_at', + 'updated_at', + ]; + $route = route('api.v1.webhooks.update', [$submission['id']]); + + $this->updateAndCompare($route, $submission, $ignore); + } + + + /** + * @return array + */ + public function updateDataProvider(): array + { + $submissions = []; + $all = $this->updateDataSet(); + foreach ($all as $name => $data) { + $submissions[] = [$data]; + } + + return $submissions; + } + + + /** + * @return array + */ + public function updateDataSet(): array + { + $faker = Factory::create(); + $set = [ + 'active' => [ + 'id' => 1, + 'fields' => [ + 'active' => ['test_value' => $faker->boolean], + ], + 'extra_ignore' => [], + ], + 'title' => [ + 'id' => 1, + 'fields' => [ + 'title' => ['test_value' => $faker->uuid], + ], + 'extra_ignore' => [], + ], + 'trigger' => [ + 'id' => 1, + 'fields' => [ + 'trigger' => ['test_value' => $faker->randomElement(['TRIGGER_STORE_TRANSACTION', 'TRIGGER_UPDATE_TRANSACTION', 'TRIGGER_DESTROY_TRANSACTION'])], + ], + 'extra_ignore' => [], + ], + 'response' => [ + 'id' => 1, + 'fields' => [ + 'response' => ['test_value' => $faker->randomElement(['RESPONSE_TRANSACTIONS', 'RESPONSE_ACCOUNTS', 'RESPONSE_NONE'])], + ], + 'extra_ignore' => [], + ], + 'delivery' => [ + 'id' => 1, + 'fields' => [ + 'delivery' => ['test_value' => $faker->randomElement(['DELIVERY_JSON'])], + ], + 'extra_ignore' => [], + ], + 'url' => [ + 'id' => 1, + 'fields' => [ + 'url' => ['test_value' => str_replace(['http://'], 'https://', $faker->url)], + ], + 'extra_ignore' => [], + ], + ]; + + return $set; + } + + +} \ No newline at end of file diff --git a/tests/Traits/TestHelpers.php b/tests/Traits/TestHelpers.php index 6a20ec6bef..7e8bafda37 100644 --- a/tests/Traits/TestHelpers.php +++ b/tests/Traits/TestHelpers.php @@ -132,6 +132,8 @@ trait TestHelpers { // get original values: $response = $this->get($route, ['Accept' => 'application/json']); + $status = $response->getStatusCode(); + $this->assertEquals($status, 200, sprintf(sprintf('%s failed with 404.', $route))); $response->assertStatus(200); $originalString = $response->content(); $originalArray = json_decode($originalString, true, 512, JSON_THROW_ON_ERROR);