From 657726e6678beedcebd240f3286b4ce8937687fe Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 21 Mar 2021 07:30:44 +0100 Subject: [PATCH] First run of all tests --- .../TransactionLink/UpdateController.php | 2 + phpunit.xml | 65 ++++++----- .../StoreControllerTest.php | 99 +++++++--------- .../UpdateControllerTest.php | 61 ++++++++-- .../TransactionLink/StoreControllerTest.php | 93 ++++++--------- .../TransactionLink/UpdateControllerTest.php | 106 ++++++++---------- .../StoreControllerTest.php | 73 ++++-------- .../UpdateControllerTest.php | 79 +++++-------- tests/Objects/TestConfiguration.php | 19 +++- 9 files changed, 276 insertions(+), 321 deletions(-) diff --git a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php index a1c3caca0b..68c65ecb53 100644 --- a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php +++ b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php @@ -53,6 +53,8 @@ class UpdateController extends Controller * * @return JsonResponse * @throws FireflyException + * + * TODO generates query exception when link exists. */ public function update(UpdateRequest $request, TransactionJournalLink $journalLink): JsonResponse { diff --git a/phpunit.xml b/phpunit.xml index 73f6dfa065..0a4cb707e6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -29,36 +29,39 @@ convertWarningsToExceptions="true" processIsolation="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> - - - ./app - - - - - - ./tests/Api/Models/Account - ./tests/Api/Models/Attachment - ./tests/Api/Models/AvailableBudget - ./tests/Api/Models/Bill - ./tests/Api/Models/Budget - ./tests/Api/Models/BudgetLimit - ./tests/Api/Models/Category - ./tests/Api/Models/ObjectGroup - ./tests/Api/Models/PiggyBank - ./tests/Api/Models/Recurrence - ./tests/Api/Models/Rule - ./tests/Api/Models/RuleGroup - ./tests/Api/Models/Tag - --> - ./tests/Api/Models/Transaction - - - - - - - - + ./tests/Api/Models/Account + ./tests/Api/Models/Attachment + ./tests/Api/Models/AvailableBudget + ./tests/Api/Models/Bill + ./tests/Api/Models/Budget + ./tests/Api/Models/BudgetLimit + ./tests/Api/Models/Category + ./tests/Api/Models/ObjectGroup + ./tests/Api/Models/PiggyBank + ./tests/Api/Models/Recurrence + ./tests/Api/Models/Rule + ./tests/Api/Models/RuleGroup + ./tests/Api/Models/Tag + ./tests/Api/Models/Transaction + ./tests/Api/Models/TransactionCurrency + ./tests/Api/Models/TransactionLink + ./tests/Api/Models/TransactionLinkType + + + + + + + + diff --git a/tests/Api/Models/TransactionCurrency/StoreControllerTest.php b/tests/Api/Models/TransactionCurrency/StoreControllerTest.php index 81b72172bd..ac6101f1c5 100644 --- a/tests/Api/Models/TransactionCurrency/StoreControllerTest.php +++ b/tests/Api/Models/TransactionCurrency/StoreControllerTest.php @@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionCurrency; use Faker\Factory; use Laravel\Passport\Passport; use Log; +use Tests\Objects\Field; +use Tests\Objects\FieldSet; +use Tests\Objects\TestConfiguration; use Tests\TestCase; use Tests\Traits\CollectsValues; @@ -61,72 +64,41 @@ class StoreControllerTest extends TestCase */ public function storeDataProvider(): array { - $minimalSets = $this->minimalSets(); - $optionalSets = $this->optionalSets(); - $regenConfig = [ - 'code' => function () { - $faker = Factory::create(); + // some test configs: + $configuration = new TestConfiguration; - return substr($faker->uuid, 0, 3); - }, - 'name' => function () { - $faker = Factory::create(); + // default test set: + $defaultSet = new FieldSet(); + $defaultSet->title = 'default_object'; + $defaultSet->addField(Field::createBasic('code', 'random-new-currency-code')); + $defaultSet->addField(Field::createBasic('name', 'uuid')); + $defaultSet->addField(Field::createBasic('symbol', 'random-new-currency-symbol')); - return $faker->uuid; - }, - 'symbol' => function () { - $faker = Factory::create(); + // 'code' => substr($faker->uuid, 0, 3), + // 'name' => $faker->uuid, + // 'symbol' => $faker->randomAscii . $faker->randomAscii, - return $faker->randomAscii . $faker->randomAscii; - }, - ]; + $configuration->addMandatoryFieldSet($defaultSet); - return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); - } + // optionals + $fieldSet = new FieldSet; + $field = Field::createBasic('enabled', 'boolean'); + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('enabled', $fieldSet); - /** - * @return array - */ - private function minimalSets(): array - { - $faker = Factory::create(); + $fieldSet = new FieldSet; + $field = Field::createBasic('default', 'boolean'); + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('default', $fieldSet); - return [ - 'default_currency' => [ - 'parameters' => [], - 'fields' => [ - 'code' => substr($faker->uuid, 0, 3), - 'name' => $faker->uuid, - 'symbol' => $faker->randomAscii . $faker->randomAscii, - ], - ], - ]; - } + $fieldSet = new FieldSet; + $field = Field::createBasic('decimal_places', 'currency-dp'); + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('decimal_places', $fieldSet); - /** - * @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), - ], - ], - ]; + return $configuration->generateAll(); + } /** @@ -139,10 +111,15 @@ class StoreControllerTest extends TestCase public function testStore(array $submission): void { if ([] === $submission) { - $this->markTestSkipped('Empty data provider'); + $this->markTestSkipped('Empty provider.'); } - $route = 'api.v1.currencies.store'; - $this->storeAndCompare($route, $submission); + Log::debug('testStoreUpdated()'); + Log::debug('submission :', $submission['submission']); + Log::debug('expected :', $submission['expected']); + Log::debug('ignore :', $submission['ignore']); + // run account store with a minimal data set: + $address = route('api.v1.currencies.store'); + $this->assertPOST($address, $submission); } } \ No newline at end of file diff --git a/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php b/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php index 008c0193f3..8a36f8bb56 100644 --- a/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php +++ b/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php @@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionCurrency; use Faker\Factory; use Laravel\Passport\Passport; use Log; +use Tests\Objects\Field; +use Tests\Objects\FieldSet; +use Tests\Objects\TestConfiguration; use Tests\TestCase; use Tests\Traits\CollectsValues; @@ -53,13 +56,17 @@ class UpdateControllerTest extends TestCase */ public function testUpdate(array $submission): void { - $ignore = [ - 'created_at', - 'updated_at', - ]; - $route = route('api.v1.currencies.update', [$submission['id']]); + if ([] === $submission) { + $this->markTestSkipped('Empty provider.'); + } + Log::debug('testStoreUpdated()'); + Log::debug('submission :', $submission['submission']); + Log::debug('expected :', $submission['expected']); + Log::debug('ignore :', $submission['ignore']); + Log::debug('parameters :', $submission['parameters']); - $this->updateAndCompare($route, $submission, $ignore); + $route = route('api.v1.currencies.update', $submission['parameters']); + $this->assertPUT($route, $submission); } @@ -68,13 +75,43 @@ class UpdateControllerTest extends TestCase */ public function updateDataProvider(): array { - $submissions = []; - $all = $this->updateDataSet(); - foreach ($all as $name => $data) { - $submissions[] = [$data]; - } + $configuration = new TestConfiguration; - return $submissions; + $fieldSet = new FieldSet; + $fieldSet->parameters = ['RMB']; + $fieldSet->addField(Field::createBasic('name', 'uuid')); + $configuration->addOptionalFieldSet('name', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = ['RMB']; + $fieldSet->addField(Field::createBasic('symbol', 'random-new-currency-symbol')); + $configuration->addOptionalFieldSet('symbol', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = ['RMB']; + $field = Field::createBasic('enabled', 'boolean'); + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('enabled', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = ['RMB']; + $field = Field::createBasic('default', 'boolean-true'); + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('default', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = ['RMB']; + $field = Field::createBasic('decimal_places', 'currency-dp'); + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('decimal_places', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = ['RMB']; + $fieldSet->addField(Field::createBasic('symbol', 'random-new-currency-code')); + $configuration->addOptionalFieldSet('code', $fieldSet); + + + return $configuration->generateAll(); } diff --git a/tests/Api/Models/TransactionLink/StoreControllerTest.php b/tests/Api/Models/TransactionLink/StoreControllerTest.php index af228a99a9..320a41da9d 100644 --- a/tests/Api/Models/TransactionLink/StoreControllerTest.php +++ b/tests/Api/Models/TransactionLink/StoreControllerTest.php @@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionLink; use Faker\Factory; use Laravel\Passport\Passport; use Log; +use Tests\Objects\Field; +use Tests\Objects\FieldSet; +use Tests\Objects\TestConfiguration; use Tests\TestCase; use Tests\Traits\CollectsValues; @@ -61,66 +64,33 @@ class StoreControllerTest extends TestCase */ public function storeDataProvider(): array { - $minimalSets = $this->minimalSets(); - $optionalSets = $this->optionalSets(); - $regenConfig = [ - 'inward_id' => function () { - $faker = Factory::create(); + // some test configs: + $configuration = new TestConfiguration; - return (string)$faker->numberBetween(1, 10); - }, - 'outward_id' => function () { - $faker = Factory::create(); + // default test set: + $defaultSet = new FieldSet(); + $defaultSet->title = 'default_object'; + $defaultSet->addField(Field::createBasic('link_type_id', 'random-link-type-id')); + $defaultSet->addField(Field::createBasic('inward_id', 'random-low-journal-id')); + $defaultSet->addField(Field::createBasic('outward_id', 'random-high-journal-id')); + $configuration->addMandatoryFieldSet($defaultSet); - return (string)$faker->numberBetween(11, 20); - }, - ]; + $defaultSet = new FieldSet(); + $defaultSet->title = 'default_object_name'; + $defaultSet->addField(Field::createBasic('link_type_name', 'random-link-type-name')); + $defaultSet->addField(Field::createBasic('inward_id', 'random-low-journal-id')); + $defaultSet->addField(Field::createBasic('outward_id', 'random-high-journal-id')); + $configuration->addMandatoryFieldSet($defaultSet); + + // optionals + $fieldSet = new FieldSet; + $fieldSet->addField(Field::createBasic('notes', 'uuid')); + $configuration->addOptionalFieldSet('notes', $fieldSet); + + return $configuration->generateAll(); - 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)), - ], - ], - ]; - } /** * @param array $submission @@ -132,10 +102,17 @@ class StoreControllerTest extends TestCase public function testStore(array $submission): void { if ([] === $submission) { - $this->markTestSkipped('Empty data provider'); + $this->markTestSkipped('Empty provider.'); } - $route = 'api.v1.transaction_links.store'; - $this->storeAndCompare($route, $submission); + Log::debug('testStoreUpdated()'); + Log::debug('submission :', $submission['submission']); + Log::debug('expected :', $submission['expected']); + Log::debug('ignore :', $submission['ignore']); + // run account store with a minimal data set: + $address = route('api.v1.transaction_links.store'); + $this->assertPOST($address, $submission); + + } } \ No newline at end of file diff --git a/tests/Api/Models/TransactionLink/UpdateControllerTest.php b/tests/Api/Models/TransactionLink/UpdateControllerTest.php index 03f8b3c8af..4fe4a03d4a 100644 --- a/tests/Api/Models/TransactionLink/UpdateControllerTest.php +++ b/tests/Api/Models/TransactionLink/UpdateControllerTest.php @@ -22,12 +22,13 @@ namespace Tests\Api\Models\TransactionLink; -use Faker\Factory; use Laravel\Passport\Passport; use Log; +use Tests\Objects\Field; +use Tests\Objects\FieldSet; +use Tests\Objects\TestConfiguration; use Tests\TestCase; use Tests\Traits\CollectsValues; - use Tests\Traits\TestHelpers; /** @@ -53,13 +54,17 @@ class UpdateControllerTest extends TestCase */ public function testUpdate(array $submission): void { - $ignore = [ - 'created_at', - 'updated_at', - ]; - $route = route('api.v1.transaction_links.update', [$submission['id']]); + if ([] === $submission) { + $this->markTestSkipped('Empty provider.'); + } + Log::debug('testStoreUpdated()'); + Log::debug('submission :', $submission['submission']); + Log::debug('expected :', $submission['expected']); + Log::debug('ignore :', $submission['ignore']); + Log::debug('parameters :', $submission['parameters']); - $this->updateAndCompare($route, $submission, $ignore); + $route = route('api.v1.transaction_links.update', $submission['parameters']); + $this->assertPUT($route, $submission); } @@ -68,61 +73,44 @@ class UpdateControllerTest extends TestCase */ public function updateDataProvider(): array { - $submissions = []; - $all = $this->updateDataSet(); - foreach ($all as $name => $data) { - $submissions[] = [$data]; - } + $configuration = new TestConfiguration; - return $submissions; - } + $fieldSet = new FieldSet; + $fieldSet->parameters = [1]; + + $field = Field::createBasic('link_type_id', 'random-link-type-id'); + $field->ignorableFields = ['link_type_name']; + + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('link_type_id', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = [1]; + + $field = Field::createBasic('link_type_name', 'random-link-type-name'); + $field->ignorableFields = ['link_type_id']; + + $fieldSet->addField($field); + $configuration->addOptionalFieldSet('link_type_name', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = [1]; + $fieldSet->addField(Field::createBasic('inward_id', 'random-low-journal-id')); + $configuration->addOptionalFieldSet('inward_id', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = [1]; + $fieldSet->addField(Field::createBasic('outward_id', 'random-high-journal-id')); + $configuration->addOptionalFieldSet('outward_id', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = [1]; + $fieldSet->addField(Field::createBasic('notes', 'uuid')); + $configuration->addOptionalFieldSet('notes', $fieldSet); - /** - * @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 $configuration->generateAll(); - return $set; } diff --git a/tests/Api/Models/TransactionLinkType/StoreControllerTest.php b/tests/Api/Models/TransactionLinkType/StoreControllerTest.php index 873eb0c21a..acbd63345b 100644 --- a/tests/Api/Models/TransactionLinkType/StoreControllerTest.php +++ b/tests/Api/Models/TransactionLinkType/StoreControllerTest.php @@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionLinkType; use Faker\Factory; use Laravel\Passport\Passport; use Log; +use Tests\Objects\Field; +use Tests\Objects\FieldSet; +use Tests\Objects\TestConfiguration; use Tests\TestCase; use Tests\Traits\CollectsValues; @@ -61,57 +64,19 @@ class StoreControllerTest extends TestCase */ public function storeDataProvider(): array { - $minimalSets = $this->minimalSets(); - $optionalSets = $this->optionalSets(); - $regenConfig = [ - 'name' => function () { - $faker = Factory::create(); + // some test configs: + $configuration = new TestConfiguration; - return $faker->uuid; - }, - 'inward' => function () { - $faker = Factory::create(); + // default test set: + $defaultSet = new FieldSet(); + $defaultSet->title = 'default_object'; + $defaultSet->addField(Field::createBasic('name', 'uuid')); + $defaultSet->addField(Field::createBasic('inward', 'uuid')); + $defaultSet->addField(Field::createBasic('outward', 'uuid')); + $configuration->addMandatoryFieldSet($defaultSet); - 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 [ - - ]; + return $configuration->generateAll(); } /** @@ -123,11 +88,17 @@ class StoreControllerTest extends TestCase */ public function testStore(array $submission): void { + if ([] === $submission) { - $this->markTestSkipped('Empty data provider'); + $this->markTestSkipped('Empty provider.'); } - $route = 'api.v1.link_types.store'; - $this->storeAndCompare($route, $submission); + Log::debug('testStoreUpdated()'); + Log::debug('submission :', $submission['submission']); + Log::debug('expected :', $submission['expected']); + Log::debug('ignore :', $submission['ignore']); + // run account store with a minimal data set: + $address = route('api.v1.link_types.store'); + $this->assertPOST($address, $submission); } } \ No newline at end of file diff --git a/tests/Api/Models/TransactionLinkType/UpdateControllerTest.php b/tests/Api/Models/TransactionLinkType/UpdateControllerTest.php index af0b70f778..60ae19a6be 100644 --- a/tests/Api/Models/TransactionLinkType/UpdateControllerTest.php +++ b/tests/Api/Models/TransactionLinkType/UpdateControllerTest.php @@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionLinkType; use Faker\Factory; use Laravel\Passport\Passport; use Log; +use Tests\Objects\Field; +use Tests\Objects\FieldSet; +use Tests\Objects\TestConfiguration; use Tests\TestCase; use Tests\Traits\CollectsValues; @@ -53,13 +56,17 @@ class UpdateControllerTest extends TestCase */ public function testUpdate(array $submission): void { - $ignore = [ - 'created_at', - 'updated_at', - ]; - $route = route('api.v1.link_types.update', [$submission['id']]); + if ([] === $submission) { + $this->markTestSkipped('Empty provider.'); + } + Log::debug('testStoreUpdated()'); + Log::debug('submission :', $submission['submission']); + Log::debug('expected :', $submission['expected']); + Log::debug('ignore :', $submission['ignore']); + Log::debug('parameters :', $submission['parameters']); - $this->updateAndCompare($route, $submission, $ignore); + $route = route('api.v1.link_types.update', $submission['parameters']); + $this->assertPUT($route, $submission); } @@ -68,48 +75,24 @@ class UpdateControllerTest extends TestCase */ public function updateDataProvider(): array { - $submissions = []; - $all = $this->updateDataSet(); - foreach ($all as $name => $data) { - $submissions[] = [$data]; - } + $configuration = new TestConfiguration; + + $fieldSet = new FieldSet; + $fieldSet->parameters = [5]; + $fieldSet->addField(Field::createBasic('name', 'uuid')); + $configuration->addOptionalFieldSet('name', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = [5]; + $fieldSet->addField(Field::createBasic('inward', 'uuid')); + $configuration->addOptionalFieldSet('inward', $fieldSet); + + $fieldSet = new FieldSet; + $fieldSet->parameters = [5]; + $fieldSet->addField(Field::createBasic('outward', 'uuid')); + $configuration->addOptionalFieldSet('outward', $fieldSet); + + return $configuration->generateAll(); - 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/Objects/TestConfiguration.php b/tests/Objects/TestConfiguration.php index f488f420ac..11588fcd23 100644 --- a/tests/Objects/TestConfiguration.php +++ b/tests/Objects/TestConfiguration.php @@ -67,7 +67,7 @@ class TestConfiguration $positions = explode('/', $value); $count = count($positions); if (1 === $count) { - $updated[$key] = $updated[$key] ? $updated[$key] : $value; + $updated[$key] = array_key_exists($key, $updated) ? $updated[$key] : $value; continue; } if (3 === $count) { @@ -286,6 +286,7 @@ class TestConfiguration if (is_array($value) && !array_key_exists($key, $left)) { $this->debugMsg(sprintf('Key %s exists in right only, keep it as it is.', $key)); $result[$key] = $right[$key]; + continue; } // value is not an array, can be appended to result (ignore the key): $this->debugMsg(sprintf('Key %s is a string (%s), just append it and return it later.', $key, $value)); @@ -401,6 +402,14 @@ class TestConfiguration return $faker->randomElement(['loan', 'debt', 'mortgage']); case 'random-journal-id': return $faker->numberBetween(1, 25); + case 'random-low-journal-id': + return $faker->numberBetween(1, 9); + case 'random-high-journal-id': + return $faker->numberBetween(10, 20); + case 'random-link-type-id': + return $faker->numberBetween(1, 4); + case 'random-link-type-name': + return $faker->randomElement(['Related', 'Refund', 'Paid', 'Reimbursement']); case 'random-amount': return number_format($faker->randomFloat(2, 10, 100), 2); case 'random-percentage': @@ -423,6 +432,8 @@ class TestConfiguration return $faker->randomElement(['withdrawal', 'deposit', 'transfer']); case 'boolean': return $faker->boolean; + case 'boolean-true': + return true; case 'iban': case 'account_number': return $faker->iban(); @@ -505,6 +516,12 @@ class TestConfiguration return $faker->randomElement(['set_category', 'add_tag', 'set_description']); case 'random-rule-group-title': return $faker->randomElement(['Rule group 1', 'Rule group 2']); + case 'random-new-currency-code': + return $faker->randomLetter . $faker->randomLetter . $faker->randomLetter; + case 'random-new-currency-symbol': + return $faker->randomAscii . $faker->randomAscii; + case 'currency-dp': + return $faker->numberBetween(0, 11); } }