Expand test code.

This commit is contained in:
James Cole
2021-03-19 06:12:28 +01:00
parent b4d44fdd2b
commit 03d3ede036
37 changed files with 1343 additions and 1187 deletions

View File

@@ -22,14 +22,11 @@
namespace Tests\Api\Models\Account;
use Faker\Factory;
use Laravel\Passport\Passport;
use Log;
use Tests\Objects\Field;
use Tests\Objects\FieldSet;
use Tests\Objects\TestConfiguration;
use Tests\Objects\TestMandatoryField;
use Tests\Objects\TestMandatoryFieldSet;
use Tests\TestCase;
use Tests\Traits\CollectsValues;
use Tests\Traits\RandomValues;
@@ -42,6 +39,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -54,323 +60,161 @@ class StoreControllerTest extends TestCase
/**
* @param array $submission
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
* newStoreDataProvider / emptyDataProvider
*
* @dataProvider newStoreDataProvider
*/
public function testStore(array $submission): void
{
$this->someTestData();
exit;
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
$this->markTestSkipped('Empty provider.');
}
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:
$route = 'api.v1.accounts.store';
$this->storeAndCompare($route, $submission);
$address = route('api.v1.accounts.store');
$this->updatedStoreAndCompare($address, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
public function newStoreDataProvider(): array
{
return [[[]]];
// some test configs:
$configuration = new TestConfiguration;
}
// default asset account test set:
$defaultAssetSet = new FieldSet();
$defaultAssetSet->title = 'default_asset_account';
$defaultAssetSet->addField(Field::createBasic('name', 'uuid'));
$defaultAssetSet->addField(Field::createBasic('type', 'static-asset'));
$defaultAssetSet->addField(Field::createBasic('account_role', 'random-asset-accountRole'));
$configuration->addMandatoryFieldSet($defaultAssetSet);
/**
* @return array
*/
public function storeDataProvider(): array
{
$minimalSets = $this->minimalSets();
$optionalSets = $this->optionalSets();
$regenConfig = [
'name' => function () {
$faker = Factory::create();
// expense test set:
$expenseSet = new FieldSet();
$expenseSet->title = 'expense_account';
$expenseSet->addField(Field::createBasic('name', 'uuid'));
return $faker->uuid;
},
'iban' => function () {
$faker = Factory::create();
// to make sure expense set ignores the opening balance fields:
$field = new Field;
$field->title = 'type';
$field->fieldTitle = 'type';
$field->fieldType = 'static-expense';
$field->ignorableFields = ['opening_balance', 'opening_balance_date', 'virtual_balance', 'order'];
$expenseSet->addField($field);
$configuration->addMandatoryFieldSet($expenseSet);
return $faker->iban();
},
'account_number' => function () {
$faker = Factory::create();
// liability test set:
$fieldSet = new FieldSet();
$fieldSet->title = 'liabilities_account';
$fieldSet->addField(Field::createBasic('name', 'uuid'));
$fieldSet->addField(Field::createBasic('type', 'static-liabilities'));
$fieldSet->addField(Field::createBasic('liability_type', 'random-liability-type'));
$fieldSet->addField(Field::createBasic('liability_amount', 'random-amount'));
$fieldSet->addField(Field::createBasic('interest', 'random-percentage'));
$fieldSet->addField(Field::createBasic('interest_period', 'random-interest-period'));
$field = new Field;
$field->fieldTitle = 'liability_start_date';
$field->fieldType = 'random-past-date';
$field->ignorableFields = ['opening_balance', 'opening_balance_date'];
$field->title = 'liability_start_date';
$fieldSet->addField($field);
$configuration->addMandatoryFieldSet($fieldSet);
return $faker->iban();
},
];
// credit card set:
$fieldSet = new FieldSet();
$fieldSet->title = 'cc_account';
$fieldSet->addField(Field::createBasic('name', 'uuid'));
$fieldSet->addField(Field::createBasic('type', 'static-asset'));
$fieldSet->addField(Field::createBasic('account_role', 'static-ccAsset'));
$fieldSet->addField(Field::createBasic('credit_card_type', 'static-monthlyFull'));
$fieldSet->addField(Field::createBasic('monthly_payment_date', 'random-past-date'));
$configuration->addMandatoryFieldSet($fieldSet);
return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig);
}
// optional field sets (for all test configs)
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('active', 'boolean'));
$configuration->addOptionalFieldSet('active', $fieldSet);
/**
* @return \array[][]
*/
private function optionalSets(): array
{
$faker = Factory::create();
$currencies = [
1 => 'EUR',
2 => 'HUF',
3 => 'GBP',
4 => 'UAH',
];
$rand = rand(1, 4);
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('iban', 'iban'));
$configuration->addOptionalFieldSet('iban', $fieldSet);
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('bic', 'bic'));
$configuration->addOptionalFieldSet('bic', $fieldSet);
return [
'active' => [
'fields' => [
'active' => $faker->boolean,
],
],
'iban' => [
'fields' => [
'iban' => $faker->iban(),
],
],
'bic' => [
'fields' => [
'bic' => $faker->swiftBicNumber,
],
],
'account_number' => [
'fields' => [
'account_number' => $faker->iban(),
],
],
'ob' => [
'fields' => [
'opening_balance' => $this->getRandomAmount(),
'opening_balance_date' => $this->getRandomDateString(),
],
],
'virtual_balance' => [
'fields' => [
'virtual_balance' => $this->getRandomAmount(),
],
],
'currency_id' => [
'fields' => [
'currency_id' => $rand,
],
],
'currency_code' => [
'fields' => [
'currency_code' => $currencies[$rand],
],
],
'order' => [
'fields' => [
'order' => $faker->numberBetween(1, 5),
],
],
'include_net_worth' => [
'fields' => [
'include_net_worth' => $faker->boolean,
],
],
'notes' => [
'fields' => [
'notes' => join(' ', $faker->words(5)),
],
],
'location' => [
'fields' => [
'latitude' => $faker->latitude,
'longitude' => $faker->longitude,
'zoom_level' => $faker->numberBetween(1, 10),
],
],
];
}
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('account_number', 'account_number'));
$configuration->addOptionalFieldSet('account_number', $fieldSet);
/**
* @return array
*/
private function minimalSets(): array
{
$faker = Factory::create();
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('opening_balance', 'random-amount'));
$fieldSet->addField(Field::createBasic('opening_balance_date', 'random-past-date'));
$configuration->addOptionalFieldSet('ob', $fieldSet);
return [
'asset' => [
'parameters' => [],
'fields' => [
'name' => $faker->uuid,
'type' => 'asset',
'account_role' => $this->randomAccountRole(),
],
],
'expense' => [
'parameters' => [],
'fields' => [
'name' => $faker->uuid,
'type' => 'expense',
],
],
'liability' => [
'parameters' => [],
'fields' => [
'name' => $faker->uuid,
'type' => 'liabilities',
'liability_type' => $this->randomLiabilityType(),
'liability_amount' => $this->getRandomAmount(),
'liability_start_date' => $this->getRandomDateString(),
'interest' => $this->getRandomPercentage(),
'interest_period' => $this->getRandomInterestPeriod(),
],
'ignore' => [
'opening_balance', 'opening_balance_date',
],
],
'cc' => [
'fields' => [
'name' => $faker->uuid,
'type' => 'asset',
'account_role' => 'ccAsset',
'credit_card_type' => 'monthlyFull',
'monthly_payment_date' => $this->getRandomDateString(),
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('virtual_balance', 'random-amount'));
$configuration->addOptionalFieldSet('virtual_balance', $fieldSet);
],
],
];
}
$fieldSet = new FieldSet;
$field = new Field;
$field->fieldTitle = 'currency_id';
$field->fieldType = 'random-currency-id';
$field->ignorableFields = ['currency_code'];
$field->title = 'currency_id';
$fieldSet->addField($field);
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
public function someTestData(): void
{
// a basic test config set contains
// mandatory fields and X optional fields
// the optional fields will be rotated automatically.
$config = new TestConfiguration;
$fieldSet = new FieldSet;
$field = new Field;
$field->fieldTitle = 'currency_code';
$field->fieldType = 'random-currency-code';
$field->ignorableFields = ['currency_id'];
$field->title = 'currency_code';
$fieldSet->addField($field);
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
// add a set of mandatory fields:
$mandatoryFieldSet = new FieldSet();
$mandatoryFieldSet->title = 'default_asset_account';
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('order', 'order'));
$configuration->addOptionalFieldSet('order', $fieldSet);
// name
$mandatoryField = new Field;
$mandatoryField->title = 'name';
$mandatoryField->fieldTitle = 'name';
$mandatoryField->fieldPosition = ''; // root
$mandatoryField->fieldType = 'uuid'; // refers to a generator or something?
$mandatoryField->expectedReturnType = 'equal'; // or 'callback'
$mandatoryField->expectedReturn = null; // or the callback
$mandatoryField->ignorableFields = [];
$mandatoryFieldSet->addField($mandatoryField);
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('include_net_worth', 'boolean'));
$configuration->addOptionalFieldSet('include_net_worth', $fieldSet);
// type
$mandatoryField = new Field;
$mandatoryField->title = 'type';
$mandatoryField->fieldTitle = 'type';
$mandatoryField->fieldPosition = ''; // root
$mandatoryField->fieldType = 'static-asset'; // refers to a generator or something?
$mandatoryField->expectedReturnType = 'equal'; // or 'callback'
$mandatoryField->expectedReturn = null; // or the callback
$mandatoryField->ignorableFields = []; // something like transactions/0/currency_code
$mandatoryFieldSet->addField($mandatoryField);
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
$configuration->addOptionalFieldSet('notes', $fieldSet);
// role
$mandatoryField = new Field;
$mandatoryField->title = 'role';
$mandatoryField->fieldTitle = 'account_role';
$mandatoryField->fieldPosition = ''; // root
$mandatoryField->fieldType = 'random-asset-accountRole'; // refers to a generator or something?
$mandatoryField->expectedReturnType = 'equal'; // or 'callback'
$mandatoryField->expectedReturn = null; // or the callback
$mandatoryField->ignorableFields = []; // something like transactions/0/currency_code
$mandatoryFieldSet->addField($mandatoryField);
$config->mandatoryFieldSet = $mandatoryFieldSet;
unset($mandatoryField);
// $mandatoryField = new TestMandatoryField;
// $mandatoryField->title = 'transaction_type';
// $mandatoryField->fieldTitle = 'type';
// $mandatoryField->fieldPosition = 'transactions/0'; // not root!
// $mandatoryField->fieldType = 'random-transactionType'; // refers to a generator or something?
// $mandatoryField->expectedReturnType = 'equal'; // or 'callback'
// $mandatoryField->expectedReturn = null; // or the callback
// $mandatoryField->ignorableFields = [];
// $mandatoryFieldSet->addMandatoryField($mandatoryField);
$fieldSet = new FieldSet;
$fieldSet->addField(Field::createBasic('latitude', 'latitude'));
$fieldSet->addField(Field::createBasic('longitude', 'longitude'));
$fieldSet->addField(Field::createBasic('zoom_level', 'random-zoom_level'));
$configuration->addOptionalFieldSet('notes', $fieldSet);
$optionalFieldSet = new FieldSet;
$optionalField = new Field;
$optionalField->title = 'active';
$optionalField->fieldTitle = 'active';
$optionalField->fieldPosition = '';
$optionalField->fieldType = 'boolean'; // refers to a generator or something?
$optionalField->expectedReturnType = 'equal'; // or 'callback'
$optionalField->expectedReturn = null; // or the callback
$optionalField->ignorableFields = []; // something like transactions/0/currency_code
$optionalFieldSet->addField($optionalField, 'active');
$optionalField = new Field;
$optionalField->title = 'iban';
$optionalField->fieldTitle = 'iban';
$optionalField->fieldPosition = '';
$optionalField->fieldType = 'iban'; // refers to a generator or something?
$optionalField->expectedReturnType = 'equal'; // or 'callback'
$optionalField->expectedReturn = null; // or the callback
$optionalField->ignorableFields = []; // something like transactions/0/currency_code
$optionalFieldSet->addField($optionalField, 'iban');
$config->optionalFieldSet = $optionalFieldSet;
// generate submissions
$arr = $config->generateSubmission();
var_dump($arr);
exit;
// generate expected returns.
$array = $configuration->generateSubmissions();
$expected = $configuration->generateExpected($array);
$ignored = $configuration->ignores;
$set = [
// set for withdrawal, copy this for
// other transaction types etc.
// make a CLASS!!
'identifier' => [
'mandatory_fields' => [
'name_of_set' => [
'fields' => [
'basic_text_field' => [
'test_value' => function () {
return 'callback';
},
'expected_return_value' => function ($input) {
// the same?
return $input;
// now create a combination for each submission and associated data:
$final = [];
foreach ($array as $index => $submission) {
$final[] = [[
'submission' => $submission,
'expected' => $expected[$index],
'ignore' => $ignored[$index],
]];
}
// a conversion?
return (string)$input;
// something else entirely?
return 'something else entirely.';
},
'ignore_other_fields' => [
'key_to_ignore',
'sub_array_like_transactions' => [0 => 'field_to_ignore'],
],
],
'another_basic_text_field' => [
// see above for 'test_value', 'expected_return_value' and 'ignore_other_fields'
],
'complex_array_field_like_transactions' => [
'transactions' => [
0 => [
'field_is_here' => [
'test_value' => null, // see above
'expected_return_value' => null, // see above
'ignore_other_fields' => [], // see above
],
],
],
],
],
],
],
// these will be permutated
'optional_fields' => [],
],
];
return $final;
}
}

View File

@@ -53,6 +53,7 @@ class UpdateControllerTest extends TestCase
*/
public function testUpdate(array $submission): void
{
$this->markTestSkipped('Skipped');
$ignore = [
'created_at',
'updated_at',
@@ -151,7 +152,7 @@ class UpdateControllerTest extends TestCase
'virtual_balance' => [
'id' => 1,
'fields' => [
'virtual_balance' => ['test_value' => number_format($faker->randomFloat(2,10,100), 2)],
'virtual_balance' => ['test_value' => number_format($faker->randomFloat(2, 10, 100), 2)],
],
'extra_ignore' => [],
],
@@ -195,7 +196,7 @@ class UpdateControllerTest extends TestCase
'ob' => [
'id' => 1,
'fields' => [
'opening_balance' => ['test_value' => number_format($faker->randomFloat(2,10,100), 2)],
'opening_balance' => ['test_value' => number_format($faker->randomFloat(2, 10, 100), 2)],
'opening_balance_date' => ['test_value' => $faker->date('Y-m-d')],
],
'extra_ignore' => [],

View File

@@ -37,33 +37,6 @@ 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');
}
// run account store with a minimal data set:
$route = 'api.v1.attachments.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
@@ -73,6 +46,15 @@ class StoreControllerTest extends TestCase
}
/**
*
*/
public function setUp(): void
{
parent::setUp();
Passport::actingAs($this->user());
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
* @return array
@@ -86,7 +68,6 @@ class StoreControllerTest extends TestCase
return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig);
}
/**
* @return array
*/
@@ -135,4 +116,21 @@ class StoreControllerTest extends TestCase
],
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
// run account store with a minimal data set:
$route = 'api.v1.attachments.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -110,7 +110,7 @@ class UpdateControllerTest extends TestCase
'id' => 1,
'fields' => [
'attachable_type' => ['test_value' => 'TransactionJournal'],
'attachable_id' => ['test_value' => (string)2],
'attachable_id' => ['test_value' => (string)2],
],
'extra_ignore' => [],
],

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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');
}
// run account store with a minimal data set:
$route = 'api.v1.available_budgets.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -85,7 +68,6 @@ class StoreControllerTest extends TestCase
return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig);
}
/**
* @return array
*/
@@ -104,7 +86,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -132,4 +113,21 @@ class StoreControllerTest extends TestCase
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
// run account store with a minimal data set:
$route = 'api.v1.available_budgets.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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');
}
// run account store with a minimal data set:
$route = 'api.v1.bills.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -91,7 +74,6 @@ class StoreControllerTest extends TestCase
return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig);
}
/**
* @return array
*/
@@ -114,7 +96,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -197,4 +178,21 @@ class StoreControllerTest extends TestCase
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
// run account store with a minimal data set:
$route = 'api.v1.bills.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -140,21 +140,21 @@ class UpdateControllerTest extends TestCase
'extra_ignore' => [],
],
'active' => [
'active' => [
'id' => 1,
'fields' => [
'active' => ['test_value' => $faker->boolean],
],
'extra_ignore' => [],
],
'notes' => [
'notes' => [
'id' => 1,
'fields' => [
'notes' => ['test_value' => join(' ', $faker->words(5))],
],
'extra_ignore' => [],
],
'object_group_id' => [
'object_group_id' => [
'id' => 1,
'fields' => [
'object_group_id' => ['test_value' => (string)$objectGroupId],
@@ -168,14 +168,14 @@ class UpdateControllerTest extends TestCase
],
'extra_ignore' => ['object_group_order', 'object_group_id'],
],
'currency_id' => [
'currency_id' => [
'id' => 1,
'fields' => [
'currency_id' => ['test_value' => (string)$rand],
],
'extra_ignore' => ['currency_code', 'currency_symbol'],
],
'currency_code' => [
'currency_code' => [
'id' => 1,
'fields' => [
'currency_code' => ['test_value' => $currencies[$rand]],

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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');
}
// run account store with a minimal data set:
$route = 'api.v1.budgets.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -91,13 +74,13 @@ class StoreControllerTest extends TestCase
return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig);
}
/**
* @return array
*/
private function minimalSets(): array
{
$faker = Factory::create();
$faker = Factory::create();
return [
'default_budget' => [
'fields' => [
@@ -107,7 +90,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -130,12 +112,12 @@ class StoreControllerTest extends TestCase
$autoBudgetType = $autoBudgetTypes[rand(0, count($autoBudgetTypes) - 1)];
return [
'active' => [
'active' => [
'fields' => [
'active' => $faker->boolean,
],
],
'auto_budget_id' => [
'auto_budget_id' => [
'fields' => [
'auto_budget_type' => $autoBudgetType,
'auto_budget_currency_id' => $rand,
@@ -143,16 +125,33 @@ class StoreControllerTest extends TestCase
'auto_budget_period' => $repeatFreq,
],
],
'auto_budget_code' => [
'auto_budget_code' => [
'fields' => [
'auto_budget_type' => $autoBudgetType,
'auto_budget_currency_code' => $currencies[$rand],
'auto_budget_amount' => number_format($faker->randomFloat(2, 10, 100), 2),
'auto_budget_period' => $repeatFreq,
],
]
],
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
// run account store with a minimal data set:
$route = 'api.v1.budgets.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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');
}
// run account store with a minimal data set:
$route = 'api.v1.budgets.limits.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -115,7 +98,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -160,4 +142,21 @@ class StoreControllerTest extends TestCase
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
// run account store with a minimal data set:
$route = 'api.v1.budgets.limits.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -105,7 +105,7 @@ class UpdateControllerTest extends TestCase
'fields' => [
'currency_id' => ['test_value' => (string)$rand],
],
'extra_ignore' => ['currency_code','currency_name','currency_symbol'],
'extra_ignore' => ['currency_code', 'currency_name', 'currency_symbol'],
],
'currency_code' => [
'id' => 1,
@@ -113,7 +113,7 @@ class UpdateControllerTest extends TestCase
'fields' => [
'currency_code' => ['test_value' => $currencies[$rand]],
],
'extra_ignore' => ['currency_id','currency_name','currency_symbol'],
'extra_ignore' => ['currency_id', 'currency_name', 'currency_symbol'],
],
'start' => [
'id' => 1,

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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.categories.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -108,7 +91,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -125,4 +107,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
$route = 'api.v1.categories.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -83,19 +83,19 @@ class UpdateControllerTest extends TestCase
*/
public function updateDataSet(): array
{
$faker = Factory::create();
$set = [
'name' => [
$faker = Factory::create();
$set = [
'name' => [
'id' => 1,
'fields' => [
'name' => ['test_value' => $faker->uuid],
],
'extra_ignore' => [],
],
'notes' => [
'notes' => [
'id' => 1,
'fields' => [
'notes' => ['test_value' => join(' ',$faker->words(5))],
'notes' => ['test_value' => join(' ', $faker->words(5))],
],
'extra_ignore' => [],
],

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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.piggy_banks.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -110,7 +93,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -160,4 +142,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
$route = 'api.v1.piggy_banks.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -99,7 +99,7 @@ class UpdateControllerTest extends TestCase
'fields' => [
'account_id' => ['test_value' => (string)$faker->numberBetween(1, 3)],
],
'extra_ignore' => ['account_name','currency_id','currency_code'],
'extra_ignore' => ['account_name', 'currency_id', 'currency_code'],
],
'target_amount' => [
'id' => 1,
@@ -146,16 +146,16 @@ class UpdateControllerTest extends TestCase
'object_group_id' => [
'id' => 1,
'fields' => [
'object_group_id' => ['test_value' => (string) $objectGroupId],
'object_group_id' => ['test_value' => (string)$objectGroupId],
],
'extra_ignore' => ['object_group_order','object_group_title'],
'extra_ignore' => ['object_group_order', 'object_group_title'],
],
'object_group_title' => [
'id' => 1,
'fields' => [
'object_group_title' => ['test_value' => $objectGroupName],
],
'extra_ignore' => ['object_group_order','object_group_id'],
'extra_ignore' => ['object_group_order', 'object_group_id'],
],
];

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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.recurrences.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -109,7 +92,7 @@ class StoreControllerTest extends TestCase
['weekly', (string)$faker->numberBetween(1, 7)],
['ndom', (string)$faker->numberBetween(1, 4) . ',' . $faker->numberBetween(1, 7)],
['monthly', (string)$faker->numberBetween(1, 31)],
['yearly', $faker->dateTimeBetween('-1 year','now')->format('Y-m-d')],
['yearly', $faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d')],
];
$set = [];
@@ -144,7 +127,6 @@ class StoreControllerTest extends TestCase
return $set;
}
/**
* @return \array[][]
*/
@@ -153,38 +135,38 @@ class StoreControllerTest extends TestCase
$faker = Factory::create();
return [
'description' => [
'description' => [
'fields' => [
'description' => $faker->uuid,
],
],
'nr_of_repetitions' => [
'nr_of_repetitions' => [
'fields' => [
'nr_of_repetitions' => $faker->numberBetween(1, 2),
],
'remove_fields' => ['repeat_until'],
],
'apply_rules' => [
'apply_rules' => [
'fields' => [
'apply_rules' => $faker->boolean,
],
],
'active' => [
'active' => [
'fields' => [
'active' => $faker->boolean,
],
],
'notes' => [
'notes' => [
'fields' => [
'notes' => $faker->uuid,
],
],
'repetitions_skip' => [
'repetitions_skip' => [
'fields' => [
'repetitions' => [
// first entry, set field:
[
'skip' => $faker->numberBetween(1,3),
'skip' => $faker->numberBetween(1, 3),
],
],
],
@@ -194,12 +176,28 @@ class StoreControllerTest extends TestCase
'repetitions' => [
// first entry, set field:
[
'weekend' => $faker->numberBetween(1,4),
'weekend' => $faker->numberBetween(1, 4),
],
],
],
]
],
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
$route = 'api.v1.recurrences.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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.rules.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -152,7 +135,6 @@ class StoreControllerTest extends TestCase
}
/**
* @return \array[][]
*/
@@ -234,4 +216,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
$route = 'api.v1.rules.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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
*/
@@ -108,7 +91,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -135,4 +117,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @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);
}
}

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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
*/
@@ -108,7 +91,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -137,4 +119,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @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);
}
}

View File

@@ -22,6 +22,7 @@
namespace Tests\Api\Models\Transaction;
use DateTimeInterface;
use Faker\Factory;
use Laravel\Passport\Passport;
use Log;
@@ -37,6 +38,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +57,6 @@ class StoreControllerTest extends TestCase
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.transactions.store';
$this->storeAndCompare($route, $submission);
}
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
* @return array
*/
@@ -117,7 +101,7 @@ class StoreControllerTest extends TestCase
'transactions' => [
[
'type' => $combi[0],
'date' => $faker->dateTime(null, 'Europe/Amsterdam')->format(\DateTimeInterface::RFC3339),
'date' => $faker->dateTime(null, 'Europe/Amsterdam')->format(DateTimeInterface::RFC3339),
'amount' => number_format($faker->randomFloat(2, 10, 100), 12),
'description' => $faker->uuid,
'source_id' => $combi[1],
@@ -131,7 +115,6 @@ class StoreControllerTest extends TestCase
return $set;
}
/**
* @return \array[][]
*/
@@ -211,4 +194,20 @@ class StoreControllerTest extends TestCase
return $set;
}
/**
* @param array $submission
*
* emptyDataProvider / storeDataProvider
*
* @dataProvider storeDataProvider
*/
public function testStore(array $submission): void
{
if ([] === $submission) {
$this->markTestSkipped('Empty data provider');
}
$route = 'api.v1.transactions.store';
$this->storeAndCompare($route, $submission);
}
}

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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
*/
@@ -81,19 +64,20 @@ class StoreControllerTest extends TestCase
$minimalSets = $this->minimalSets();
$optionalSets = $this->optionalSets();
$regenConfig = [
'code' => function () {
'code' => function () {
$faker = Factory::create();
return substr($faker->uuid, 0, 3);
},
'name' => function () {
'name' => function () {
$faker = Factory::create();
return $faker->uuid;
},
'symbol' => function () {
$faker = Factory::create();
return $faker->randomAscii.$faker->randomAscii;
return $faker->randomAscii . $faker->randomAscii;
},
];
@@ -113,13 +97,12 @@ class StoreControllerTest extends TestCase
'fields' => [
'code' => substr($faker->uuid, 0, 3),
'name' => $faker->uuid,
'symbol' => $faker->randomAscii.$faker->randomAscii,
'symbol' => $faker->randomAscii . $faker->randomAscii,
],
],
];
}
/**
* @return \array[][]
*/
@@ -133,12 +116,12 @@ class StoreControllerTest extends TestCase
'enabled' => $faker->boolean,
],
],
'default' => [
'default' => [
'fields' => [
'default' => $faker->boolean,
],
],
'decimal_places' => [
'decimal_places' => [
'fields' => [
'decimal_places' => $faker->numberBetween(1, 6),
],
@@ -146,4 +129,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @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);
}
}

View File

@@ -102,7 +102,7 @@ class UpdateControllerTest extends TestCase
'symbol' => [
'id' => 'RUB',
'fields' => [
'description' => ['test_value' => $faker->randomAscii.$faker->randomAscii],
'description' => ['test_value' => $faker->randomAscii . $faker->randomAscii],
],
'extra_ignore' => [],
],

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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
*/
@@ -123,7 +106,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -140,4 +122,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @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);
}
}

View File

@@ -85,35 +85,35 @@ class UpdateControllerTest extends TestCase
{
$faker = Factory::create();
$set = [
'link_type_id' => [
'link_type_id' => [
'id' => 1,
'fields' => [
'link_type_id' => ['test_value' => (string)$faker->numberBetween(1,3)],
'link_type_id' => ['test_value' => (string)$faker->numberBetween(1, 3)],
],
'extra_ignore' => ['link_type_name'],
],
'link_type_name' => [
'link_type_name' => [
'id' => 1,
'fields' => [
'link_type_name' => ['test_value' => 'Refund'],
],
'extra_ignore' => ['link_type_id'],
],
'inward_id' => [
'inward_id' => [
'id' => 1,
'fields' => [
'inward_id' => ['test_value' => (string)$faker->numberBetween(11,20)],
'inward_id' => ['test_value' => (string)$faker->numberBetween(11, 20)],
],
'extra_ignore' => [],
],
'outward_id' => [
'outward_id' => [
'id' => 1,
'fields' => [
'outward_id' => ['test_value' => (string)$faker->numberBetween(11, 30)],
],
'extra_ignore' => [],
],
'notes' => [
'notes' => [
'id' => 1,
'fields' => [
'notes' => ['test_value' => join(' ', $faker->words(5))],

View File

@@ -37,6 +37,15 @@ class StoreControllerTest extends TestCase
{
use RandomValues, TestHelpers, CollectsValues;
/**
* @return array
*/
public function emptyDataProvider(): array
{
return [[[]]];
}
/**
*
*/
@@ -47,32 +56,6 @@ class StoreControllerTest extends TestCase
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
*/
@@ -121,7 +104,6 @@ class StoreControllerTest extends TestCase
];
}
/**
* @return \array[][]
*/
@@ -132,4 +114,20 @@ class StoreControllerTest extends TestCase
];
}
/**
* @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);
}
}