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');
}
$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);
}
}