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

@@ -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);
}
}