Max out the number of iterations

This commit is contained in:
James Cole
2021-03-14 04:55:48 +01:00
parent fc4d4a455b
commit d82fe2ab4c
13 changed files with 23 additions and 19 deletions

View File

@@ -60,6 +60,7 @@ return [
'less' => ':attribute must be less than 10,000,000', 'less' => ':attribute must be less than 10,000,000',
'active_url' => 'The :attribute is not a valid URL.', 'active_url' => 'The :attribute is not a valid URL.',
'after' => 'The :attribute must be a date after :date.', 'after' => 'The :attribute must be a date after :date.',
'date_after' => 'End date must be before start date.',
'alpha' => 'The :attribute may only contain letters.', 'alpha' => 'The :attribute may only contain letters.',
'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
'alpha_num' => 'The :attribute may only contain letters and numbers.', 'alpha_num' => 'The :attribute may only contain letters and numbers.',

View File

@@ -50,7 +50,7 @@ class StoreControllerTest extends TestCase
/** /**
* @param array $submission * @param array $submission
* emptyDataProvider / storeDataProvider * emptyDataProvider / storeDataProvider
* @dataProvider emptyDataProvider * @dataProvider storeDataProvider
*/ */
public function testStore(array $submission): void public function testStore(array $submission): void
{ {
@@ -193,7 +193,7 @@ class StoreControllerTest extends TestCase
'asset' => [ 'asset' => [
'parameters' => [], 'parameters' => [],
'fields' => [ 'fields' => [
'name' => $faker->name . join(' ', $faker->words(2)), 'name' => $faker->uuid,
'type' => 'asset', 'type' => 'asset',
'account_role' => $this->randomAccountRole(), 'account_role' => $this->randomAccountRole(),
], ],
@@ -201,14 +201,14 @@ class StoreControllerTest extends TestCase
'expense' => [ 'expense' => [
'parameters' => [], 'parameters' => [],
'fields' => [ 'fields' => [
'name' => $faker->name, 'name' => $faker->uuid,
'type' => 'expense', 'type' => 'expense',
], ],
], ],
'liability' => [ 'liability' => [
'parameters' => [], 'parameters' => [],
'fields' => [ 'fields' => [
'name' => $faker->name, 'name' => $faker->uuid,
'type' => 'liabilities', 'type' => 'liabilities',
'liability_type' => $this->randomLiabilityType(), 'liability_type' => $this->randomLiabilityType(),
'liability_amount' => $this->getRandomAmount(), 'liability_amount' => $this->getRandomAmount(),
@@ -219,7 +219,7 @@ class StoreControllerTest extends TestCase
], ],
'cc' => [ 'cc' => [
'fields' => [ 'fields' => [
'name' => $faker->name, 'name' => $faker->uuid,
'type' => 'asset', 'type' => 'asset',
'account_role' => 'ccAsset', 'account_role' => 'ccAsset',
'credit_card_type' => 'monthlyFull', 'credit_card_type' => 'monthlyFull',

View File

@@ -102,7 +102,7 @@ class UpdateControllerTest extends TestCase
'name' => [ 'name' => [
'id' => 1, 'id' => 1,
'fields' => [ 'fields' => [
'name' => ['test_value' => $faker->text(64)], 'name' => ['test_value' => $faker->uuid],
], ],
'extra_ignore' => [], 'extra_ignore' => [],
], ],

View File

@@ -52,7 +52,7 @@ class StoreControllerTest extends TestCase
* @param array $submission * @param array $submission
* *
* emptyDataProvider / storeDataProvider * emptyDataProvider / storeDataProvider
* @dataProvider emptyDataProvider * @dataProvider storeDataProvider
*/ */
public function testStore(array $submission): void public function testStore(array $submission): void
{ {
@@ -125,7 +125,7 @@ class StoreControllerTest extends TestCase
return [ return [
'title' => [ 'title' => [
'fields' => [ 'fields' => [
'title' => join(' ', $faker->words(3)), 'title' => $faker->uuid,
], ],
], ],
'notes' => [ 'notes' => [

View File

@@ -95,7 +95,7 @@ class UpdateControllerTest extends TestCase
'title' => [ 'title' => [
'id' => 1, 'id' => 1,
'fields' => [ 'fields' => [
'title' => ['test_value' => $faker->text(64)], 'title' => ['test_value' => $faker->uuid],
], ],
'extra_ignore' => [], 'extra_ignore' => [],
], ],

View File

@@ -52,7 +52,7 @@ class StoreControllerTest extends TestCase
* @param array $submission * @param array $submission
* *
* emptyDataProvider / storeDataProvider * emptyDataProvider / storeDataProvider
* @dataProvider emptyDataProvider * @dataProvider storeDataProvider
*/ */
public function testStore(array $submission): void public function testStore(array $submission): void
{ {

View File

@@ -52,7 +52,7 @@ class StoreControllerTest extends TestCase
* @param array $submission * @param array $submission
* *
* emptyDataProvider / storeDataProvider * emptyDataProvider / storeDataProvider
* @dataProvider emptyDataProvider * @dataProvider storeDataProvider
*/ */
public function testStore(array $submission): void public function testStore(array $submission): void
{ {
@@ -104,7 +104,7 @@ class StoreControllerTest extends TestCase
return [ return [
'default_bill' => [ 'default_bill' => [
'fields' => [ 'fields' => [
'name' => join(',', $faker->words(5)), 'name' => $faker->uuid,
'amount_min' => number_format($faker->randomFloat(2, 10, 50), 2), 'amount_min' => number_format($faker->randomFloat(2, 10, 50), 2),
'amount_max' => number_format($faker->randomFloat(2, 60, 90), 2), 'amount_max' => number_format($faker->randomFloat(2, 60, 90), 2),
'date' => $faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d'), 'date' => $faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d'),
@@ -146,7 +146,7 @@ class StoreControllerTest extends TestCase
], ],
'name' => [ 'name' => [
'fields' => [ 'fields' => [
'name' => join(' ', $faker->words(5)), 'name' => $faker->uuid,
], ],
], ],
'amount_min' => [ 'amount_min' => [

View File

@@ -99,7 +99,7 @@ class UpdateControllerTest extends TestCase
'name' => [ 'name' => [
'id' => 1, 'id' => 1,
'fields' => [ 'fields' => [
'name' => ['test_value' => join(' ', $faker->words(4))], 'name' => ['test_value' => $faker->uuid],
], ],
'extra_ignore' => [], 'extra_ignore' => [],
], ],

View File

@@ -52,7 +52,7 @@ class StoreControllerTest extends TestCase
* @param array $submission * @param array $submission
* *
* emptyDataProvider / storeDataProvider * emptyDataProvider / storeDataProvider
* @dataProvider emptyDataProvider * @dataProvider storeDataProvider
*/ */
public function testStore(array $submission): void public function testStore(array $submission): void
{ {
@@ -101,7 +101,7 @@ class StoreControllerTest extends TestCase
return [ return [
'default_budget' => [ 'default_budget' => [
'fields' => [ 'fields' => [
'name' => join(',', $faker->words(5)), 'name' => $faker->uuid,
], ],
], ],
]; ];

View File

@@ -103,7 +103,7 @@ class UpdateControllerTest extends TestCase
'name' => [ 'name' => [
'id' => 1, 'id' => 1,
'fields' => [ 'fields' => [
'name' => ['test_value' => join(' ', $faker->words(4))], 'name' => ['test_value' => $faker->uuid],
], ],
'extra_ignore' => [], 'extra_ignore' => [],
], ],

View File

@@ -52,7 +52,7 @@ class StoreControllerTest extends TestCase
* @param array $submission * @param array $submission
* *
* emptyDataProvider / storeDataProvider * emptyDataProvider / storeDataProvider
* @dataProvider emptyDataProvider * @dataProvider storeDataProvider
*/ */
public function testStore(array $submission): void public function testStore(array $submission): void
{ {

View File

@@ -32,6 +32,7 @@ use Tests\Traits\CollectsValues;
abstract class TestCase extends BaseTestCase abstract class TestCase extends BaseTestCase
{ {
use CreatesApplication, CollectsValues; use CreatesApplication, CollectsValues;
protected const MAX_ITERATIONS = 2;
/** /**
* @return array * @return array

View File

@@ -53,7 +53,8 @@ trait TestHelpers
// then loop and add fields: // then loop and add fields:
$optionalSets = $startOptionalSets; $optionalSets = $startOptionalSets;
$keys = array_keys($optionalSets); $keys = array_keys($optionalSets);
for ($i = 1; $i <= count($keys); $i++) { $count = count($keys) > self::MAX_ITERATIONS ? self::MAX_ITERATIONS : count($keys);
for ($i = 1; $i <= $count; $i++) {
$combinations = $this->combinationsOf($i, $keys); $combinations = $this->combinationsOf($i, $keys);
// expand body with N extra fields: // expand body with N extra fields:
foreach ($combinations as $extraFields) { foreach ($combinations as $extraFields) {
@@ -71,6 +72,7 @@ trait TestHelpers
} }
unset($second); unset($second);
} }
return $submissions; return $submissions;
} }