mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code fixes.
This commit is contained in:
@@ -21,10 +21,11 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Objects;
|
||||
|
||||
use Faker\Factory;
|
||||
use RuntimeException;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Class TestConfiguration
|
||||
@@ -70,10 +71,10 @@ class TestConfiguration
|
||||
{
|
||||
$this->debugMsg('Now in generateAll()');
|
||||
// generate submissions
|
||||
$array = $this->generateSubmissions();
|
||||
$parameters = $this->parameters;
|
||||
$ignored = $this->ignores;
|
||||
$expected = $this->expected;
|
||||
$array = $this->generateSubmissions();
|
||||
$allParameters = $this->parameters;
|
||||
$ignored = $this->ignores;
|
||||
$expectedValue = $this->expected;
|
||||
|
||||
$this->debugMsg(sprintf('Now validating %d ignored() values.', count($ignored)));
|
||||
|
||||
@@ -111,9 +112,9 @@ class TestConfiguration
|
||||
foreach ($array as $index => $submission) {
|
||||
$final[] = [[
|
||||
'submission' => $submission,
|
||||
'expected' => $expected[$index] ?? $submission,
|
||||
'expected' => $expectedValue[$index] ?? $submission,
|
||||
'ignore' => $newIgnored[$index] ?? [],
|
||||
'parameters' => $parameters[$index] ?? [],
|
||||
'parameters' => $allParameters[$index] ?? [],
|
||||
]];
|
||||
}
|
||||
|
||||
@@ -205,7 +206,7 @@ class TestConfiguration
|
||||
$this->debugMsg(sprintf(' Set #%d will consist of:', $totalCount));
|
||||
// the custom set is born!
|
||||
$custom = [];
|
||||
$expected = [];
|
||||
$expectedValue = [];
|
||||
foreach ($combinationSet as $combination) {
|
||||
$this->debugMsg(sprintf(' %s', $combination));
|
||||
// here we start adding stuff to a copy of the standard submission.
|
||||
@@ -217,7 +218,7 @@ class TestConfiguration
|
||||
foreach ($customSet->fields as $field) {
|
||||
$this->debugMsg(sprintf(' added field "%s" from custom set "%s"', $field->fieldTitle, $combination));
|
||||
$custom = $this->parseField($custom, $field);
|
||||
$expected = $this->parseExpected($expected, $field, $custom);
|
||||
$expectedValue = $this->parseExpected($expectedValue, $field, $custom);
|
||||
// for each field, add the ignores to the current index (+1!) of
|
||||
// ignores.
|
||||
$count = count($this->submission);
|
||||
@@ -248,7 +249,7 @@ class TestConfiguration
|
||||
|
||||
$this->debugMsg(sprintf(' New set of ignore things (%d) is: %s', $count, json_encode($this->ignores[$count])));
|
||||
}
|
||||
$this->expected[$count] = $expected;
|
||||
$this->expected[$count] = $expectedValue;
|
||||
}
|
||||
$count = count($this->submission);
|
||||
$this->parameters[$count] = $customSet->parameters ?? [];
|
||||
@@ -341,12 +342,12 @@ class TestConfiguration
|
||||
{
|
||||
$ignore = [];
|
||||
$result = [];
|
||||
$expected = [];
|
||||
$expectedValue = [];
|
||||
/** @var Field $field */
|
||||
foreach ($set->fields as $field) {
|
||||
// this is what we will submit:
|
||||
$result = $this->parseField($result, $field);
|
||||
$expected = $this->parseExpected($expected, $field, $result);
|
||||
$expectedValue = $this->parseExpected($expectedValue, $field, $result);
|
||||
|
||||
// this is what we will ignore:
|
||||
$newIgnore = array_unique($ignore + $field->ignorableFields);
|
||||
@@ -355,7 +356,7 @@ class TestConfiguration
|
||||
|
||||
}
|
||||
$this->ignores[] = array_values($ignore);
|
||||
$this->expected[] = $expected;
|
||||
$this->expected[] = $expectedValue;
|
||||
$this->parameters[] = $set->parameters ?? [];
|
||||
|
||||
return $result;
|
||||
@@ -388,7 +389,7 @@ class TestConfiguration
|
||||
|
||||
return $current;
|
||||
}
|
||||
throw new RuntimeException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));
|
||||
throw new UnexpectedValueException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +402,7 @@ class TestConfiguration
|
||||
$faker = Factory::create();
|
||||
switch ($type) {
|
||||
default:
|
||||
throw new RuntimeException(sprintf('Cannot handle field "%s"', $type));
|
||||
throw new UnexpectedValueException(sprintf('Cannot handle field "%s"', $type));
|
||||
case 'uuid':
|
||||
return $faker->uuid;
|
||||
case 'static-asset':
|
||||
@@ -604,7 +605,7 @@ class TestConfiguration
|
||||
|
||||
return $expected;
|
||||
}
|
||||
throw new RuntimeException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));
|
||||
throw new UnexpectedValueException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user