First run of all tests

This commit is contained in:
James Cole
2021-03-21 07:30:44 +01:00
parent eb90dac89d
commit 657726e667
9 changed files with 276 additions and 321 deletions

View File

@@ -53,6 +53,8 @@ class UpdateController extends Controller
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @throws FireflyException
*
* TODO generates query exception when link exists.
*/ */
public function update(UpdateRequest $request, TransactionJournalLink $journalLink): JsonResponse public function update(UpdateRequest $request, TransactionJournalLink $journalLink): JsonResponse
{ {

View File

@@ -29,36 +29,39 @@
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true"> <coverage processUncoveredFiles="true">
<include> <include>
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
</include> </include>
</coverage> </coverage>
<testsuites> <testsuites>
<testsuite name="Api"> <testsuite name="Api">
<!-- <!--
-->
<directory suffix="Test.php">./tests/Api/Models/Account</directory> <directory suffix="Test.php">./tests/Api/Models/Account</directory>
<directory suffix="Test.php">./tests/Api/Models/Attachment</directory> <directory suffix="Test.php">./tests/Api/Models/Attachment</directory>
<directory suffix="Test.php">./tests/Api/Models/AvailableBudget</directory> <directory suffix="Test.php">./tests/Api/Models/AvailableBudget</directory>
<directory suffix="Test.php">./tests/Api/Models/Bill</directory> <directory suffix="Test.php">./tests/Api/Models/Bill</directory>
<directory suffix="Test.php">./tests/Api/Models/Budget</directory> <directory suffix="Test.php">./tests/Api/Models/Budget</directory>
<directory suffix="Test.php">./tests/Api/Models/BudgetLimit</directory> <directory suffix="Test.php">./tests/Api/Models/BudgetLimit</directory>
<directory suffix="Test.php">./tests/Api/Models/Category</directory> <directory suffix="Test.php">./tests/Api/Models/Category</directory>
<directory suffix="Test.php">./tests/Api/Models/ObjectGroup</directory> <directory suffix="Test.php">./tests/Api/Models/ObjectGroup</directory>
<directory suffix="Test.php">./tests/Api/Models/PiggyBank</directory> <directory suffix="Test.php">./tests/Api/Models/PiggyBank</directory>
<directory suffix="Test.php">./tests/Api/Models/Recurrence</directory> <directory suffix="Test.php">./tests/Api/Models/Recurrence</directory>
<directory suffix="Test.php">./tests/Api/Models/Rule</directory> <directory suffix="Test.php">./tests/Api/Models/Rule</directory>
<directory suffix="Test.php">./tests/Api/Models/RuleGroup</directory> <directory suffix="Test.php">./tests/Api/Models/RuleGroup</directory>
<directory suffix="Test.php">./tests/Api/Models/Tag</directory> <directory suffix="Test.php">./tests/Api/Models/Tag</directory>
--> <directory suffix="Test.php">./tests/Api/Models/Transaction</directory>
<directory suffix="Test.php">./tests/Api/Models/Transaction</directory> <directory suffix="Test.php">./tests/Api/Models/TransactionCurrency</directory>
</testsuite> <directory suffix="Test.php">./tests/Api/Models/TransactionLink</directory>
</testsuites> <directory suffix="Test.php">./tests/Api/Models/TransactionLinkType</directory>
<php> </testsuite>
<env name="APP_ENV" value="testing"/> </testsuites>
<env name="CACHE_DRIVER" value="array"/> <php>
<env name="SESSION_DRIVER" value="array"/> <env name="APP_ENV" value="testing"/>
<env name="QUEUE_DRIVER" value="sync"/> <env name="CACHE_DRIVER" value="array"/>
</php> <env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit> </phpunit>

View File

@@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionCurrency;
use Faker\Factory; use Faker\Factory;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Log; use Log;
use Tests\Objects\Field;
use Tests\Objects\FieldSet;
use Tests\Objects\TestConfiguration;
use Tests\TestCase; use Tests\TestCase;
use Tests\Traits\CollectsValues; use Tests\Traits\CollectsValues;
@@ -61,72 +64,41 @@ class StoreControllerTest extends TestCase
*/ */
public function storeDataProvider(): array public function storeDataProvider(): array
{ {
$minimalSets = $this->minimalSets(); // some test configs:
$optionalSets = $this->optionalSets(); $configuration = new TestConfiguration;
$regenConfig = [
'code' => function () {
$faker = Factory::create();
return substr($faker->uuid, 0, 3); // default test set:
}, $defaultSet = new FieldSet();
'name' => function () { $defaultSet->title = 'default_object';
$faker = Factory::create(); $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; // 'code' => substr($faker->uuid, 0, 3),
}, // 'name' => $faker->uuid,
'symbol' => function () { // 'symbol' => $faker->randomAscii . $faker->randomAscii,
$faker = Factory::create();
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);
/** $fieldSet = new FieldSet;
* @return array $field = Field::createBasic('default', 'boolean');
*/ $fieldSet->addField($field);
private function minimalSets(): array $configuration->addOptionalFieldSet('default', $fieldSet);
{
$faker = Factory::create();
return [ $fieldSet = new FieldSet;
'default_currency' => [ $field = Field::createBasic('decimal_places', 'currency-dp');
'parameters' => [], $fieldSet->addField($field);
'fields' => [ $configuration->addOptionalFieldSet('decimal_places', $fieldSet);
'code' => substr($faker->uuid, 0, 3),
'name' => $faker->uuid,
'symbol' => $faker->randomAscii . $faker->randomAscii,
],
],
];
}
/**
* @return \array[][]
*/
private function optionalSets(): array
{
$faker = Factory::create();
return [ return $configuration->generateAll();
'enabled' => [
'fields' => [
'enabled' => $faker->boolean,
],
],
'default' => [
'fields' => [
'default' => $faker->boolean,
],
],
'decimal_places' => [
'fields' => [
'decimal_places' => $faker->numberBetween(1, 6),
],
],
];
} }
/** /**
@@ -139,10 +111,15 @@ class StoreControllerTest extends TestCase
public function testStore(array $submission): void public function testStore(array $submission): void
{ {
if ([] === $submission) { if ([] === $submission) {
$this->markTestSkipped('Empty data provider'); $this->markTestSkipped('Empty provider.');
} }
$route = 'api.v1.currencies.store'; Log::debug('testStoreUpdated()');
$this->storeAndCompare($route, $submission); 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);
} }
} }

View File

@@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionCurrency;
use Faker\Factory; use Faker\Factory;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Log; use Log;
use Tests\Objects\Field;
use Tests\Objects\FieldSet;
use Tests\Objects\TestConfiguration;
use Tests\TestCase; use Tests\TestCase;
use Tests\Traits\CollectsValues; use Tests\Traits\CollectsValues;
@@ -53,13 +56,17 @@ class UpdateControllerTest extends TestCase
*/ */
public function testUpdate(array $submission): void public function testUpdate(array $submission): void
{ {
$ignore = [ if ([] === $submission) {
'created_at', $this->markTestSkipped('Empty provider.');
'updated_at', }
]; Log::debug('testStoreUpdated()');
$route = route('api.v1.currencies.update', [$submission['id']]); 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 public function updateDataProvider(): array
{ {
$submissions = []; $configuration = new TestConfiguration;
$all = $this->updateDataSet();
foreach ($all as $name => $data) {
$submissions[] = [$data];
}
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();
} }

View File

@@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionLink;
use Faker\Factory; use Faker\Factory;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Log; use Log;
use Tests\Objects\Field;
use Tests\Objects\FieldSet;
use Tests\Objects\TestConfiguration;
use Tests\TestCase; use Tests\TestCase;
use Tests\Traits\CollectsValues; use Tests\Traits\CollectsValues;
@@ -61,66 +64,33 @@ class StoreControllerTest extends TestCase
*/ */
public function storeDataProvider(): array public function storeDataProvider(): array
{ {
$minimalSets = $this->minimalSets(); // some test configs:
$optionalSets = $this->optionalSets(); $configuration = new TestConfiguration;
$regenConfig = [
'inward_id' => function () {
$faker = Factory::create();
return (string)$faker->numberBetween(1, 10); // default test set:
}, $defaultSet = new FieldSet();
'outward_id' => function () { $defaultSet->title = 'default_object';
$faker = Factory::create(); $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 * @param array $submission
@@ -132,10 +102,17 @@ class StoreControllerTest extends TestCase
public function testStore(array $submission): void public function testStore(array $submission): void
{ {
if ([] === $submission) { if ([] === $submission) {
$this->markTestSkipped('Empty data provider'); $this->markTestSkipped('Empty provider.');
} }
$route = 'api.v1.transaction_links.store'; Log::debug('testStoreUpdated()');
$this->storeAndCompare($route, $submission); 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);
} }
} }

View File

@@ -22,12 +22,13 @@
namespace Tests\Api\Models\TransactionLink; namespace Tests\Api\Models\TransactionLink;
use Faker\Factory;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Log; use Log;
use Tests\Objects\Field;
use Tests\Objects\FieldSet;
use Tests\Objects\TestConfiguration;
use Tests\TestCase; use Tests\TestCase;
use Tests\Traits\CollectsValues; use Tests\Traits\CollectsValues;
use Tests\Traits\TestHelpers; use Tests\Traits\TestHelpers;
/** /**
@@ -53,13 +54,17 @@ class UpdateControllerTest extends TestCase
*/ */
public function testUpdate(array $submission): void public function testUpdate(array $submission): void
{ {
$ignore = [ if ([] === $submission) {
'created_at', $this->markTestSkipped('Empty provider.');
'updated_at', }
]; Log::debug('testStoreUpdated()');
$route = route('api.v1.transaction_links.update', [$submission['id']]); 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 public function updateDataProvider(): array
{ {
$submissions = []; $configuration = new TestConfiguration;
$all = $this->updateDataSet();
foreach ($all as $name => $data) {
$submissions[] = [$data];
}
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 $configuration->generateAll();
* @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;
} }

View File

@@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionLinkType;
use Faker\Factory; use Faker\Factory;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Log; use Log;
use Tests\Objects\Field;
use Tests\Objects\FieldSet;
use Tests\Objects\TestConfiguration;
use Tests\TestCase; use Tests\TestCase;
use Tests\Traits\CollectsValues; use Tests\Traits\CollectsValues;
@@ -61,57 +64,19 @@ class StoreControllerTest extends TestCase
*/ */
public function storeDataProvider(): array public function storeDataProvider(): array
{ {
$minimalSets = $this->minimalSets(); // some test configs:
$optionalSets = $this->optionalSets(); $configuration = new TestConfiguration;
$regenConfig = [
'name' => function () {
$faker = Factory::create();
return $faker->uuid; // default test set:
}, $defaultSet = new FieldSet();
'inward' => function () { $defaultSet->title = 'default_object';
$faker = Factory::create(); $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 $configuration->generateAll();
},
];
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 [
];
} }
/** /**
@@ -123,11 +88,17 @@ class StoreControllerTest extends TestCase
*/ */
public function testStore(array $submission): void public function testStore(array $submission): void
{ {
if ([] === $submission) { if ([] === $submission) {
$this->markTestSkipped('Empty data provider'); $this->markTestSkipped('Empty provider.');
} }
$route = 'api.v1.link_types.store'; Log::debug('testStoreUpdated()');
$this->storeAndCompare($route, $submission); 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);
} }
} }

View File

@@ -25,6 +25,9 @@ namespace Tests\Api\Models\TransactionLinkType;
use Faker\Factory; use Faker\Factory;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Log; use Log;
use Tests\Objects\Field;
use Tests\Objects\FieldSet;
use Tests\Objects\TestConfiguration;
use Tests\TestCase; use Tests\TestCase;
use Tests\Traits\CollectsValues; use Tests\Traits\CollectsValues;
@@ -53,13 +56,17 @@ class UpdateControllerTest extends TestCase
*/ */
public function testUpdate(array $submission): void public function testUpdate(array $submission): void
{ {
$ignore = [ if ([] === $submission) {
'created_at', $this->markTestSkipped('Empty provider.');
'updated_at', }
]; Log::debug('testStoreUpdated()');
$route = route('api.v1.link_types.update', [$submission['id']]); 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 public function updateDataProvider(): array
{ {
$submissions = []; $configuration = new TestConfiguration;
$all = $this->updateDataSet();
foreach ($all as $name => $data) { $fieldSet = new FieldSet;
$submissions[] = [$data]; $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;
}
} }

View File

@@ -67,7 +67,7 @@ class TestConfiguration
$positions = explode('/', $value); $positions = explode('/', $value);
$count = count($positions); $count = count($positions);
if (1 === $count) { if (1 === $count) {
$updated[$key] = $updated[$key] ? $updated[$key] : $value; $updated[$key] = array_key_exists($key, $updated) ? $updated[$key] : $value;
continue; continue;
} }
if (3 === $count) { if (3 === $count) {
@@ -286,6 +286,7 @@ class TestConfiguration
if (is_array($value) && !array_key_exists($key, $left)) { if (is_array($value) && !array_key_exists($key, $left)) {
$this->debugMsg(sprintf('Key %s exists in right only, keep it as it is.', $key)); $this->debugMsg(sprintf('Key %s exists in right only, keep it as it is.', $key));
$result[$key] = $right[$key]; $result[$key] = $right[$key];
continue;
} }
// value is not an array, can be appended to result (ignore the key): // 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)); $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']); return $faker->randomElement(['loan', 'debt', 'mortgage']);
case 'random-journal-id': case 'random-journal-id':
return $faker->numberBetween(1, 25); 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': case 'random-amount':
return number_format($faker->randomFloat(2, 10, 100), 2); return number_format($faker->randomFloat(2, 10, 100), 2);
case 'random-percentage': case 'random-percentage':
@@ -423,6 +432,8 @@ class TestConfiguration
return $faker->randomElement(['withdrawal', 'deposit', 'transfer']); return $faker->randomElement(['withdrawal', 'deposit', 'transfer']);
case 'boolean': case 'boolean':
return $faker->boolean; return $faker->boolean;
case 'boolean-true':
return true;
case 'iban': case 'iban':
case 'account_number': case 'account_number':
return $faker->iban(); return $faker->iban();
@@ -505,6 +516,12 @@ class TestConfiguration
return $faker->randomElement(['set_category', 'add_tag', 'set_description']); return $faker->randomElement(['set_category', 'add_tag', 'set_description']);
case 'random-rule-group-title': case 'random-rule-group-title':
return $faker->randomElement(['Rule group 1', 'Rule group 2']); 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);
} }
} }