diff --git a/phpunit.xml b/phpunit.xml
index 999d2411bd..09f8267509 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -36,7 +36,7 @@
- ./tests/Api/Models/PiggyBank
+ ./tests/Api/Models
diff --git a/tests/Api/Models/Transaction/StoreControllerTest.php b/tests/Api/Models/Transaction/StoreControllerTest.php
index 3a89805f4b..4b77363e71 100644
--- a/tests/Api/Models/Transaction/StoreControllerTest.php
+++ b/tests/Api/Models/Transaction/StoreControllerTest.php
@@ -81,11 +81,6 @@ class StoreControllerTest extends TestCase
$minimalSets = $this->minimalSets();
$optionalSets = $this->optionalSets();
$regenConfig = [
- 'title' => function () {
- $faker = Factory::create();
-
- return $faker->uuid;
- },
'transactions' => [
[
'description' => function () {
@@ -118,7 +113,6 @@ class StoreControllerTest extends TestCase
$set[] = [
'parameters' => [],
'fields' => [
- // not even required but OK.
'error_if_duplicate_hash' => $faker->boolean,
'transactions' => [
[
@@ -144,24 +138,77 @@ class StoreControllerTest extends TestCase
private function optionalSets(): array
{
$faker = Factory::create();
-
- return [
- 'title' => [
+ $set = [
+ 'transactions_currency_id' => [
'fields' => [
- 'title' => $faker->uuid,
+ 'transactions' => [
+ // first entry, set field:
+ [
+ 'currency_id' => $faker->numberBetween(1, 1),
+ ],
+ ],
],
],
- 'order' => [
+ 'transactions_currency_code' => [
'fields' => [
- 'order' => $faker->numberBetween(1, 2),
+ 'transactions' => [
+ // first entry, set field:
+ [
+ 'currency_code' => $faker->randomElement(['EUR']),
+ ],
+ ],
],
],
- 'active' => [
+ // category id
+ 'category_id' => [
'fields' => [
- 'active' => $faker->boolean,
+ 'transactions' => [
+ // first entry, set field:
+ [
+ 'category_id' => '1',
+ ],
+ ],
+ ],
+ ],
+ // reconciled
+ 'reconciled' => [
+ 'fields' => [
+ 'transactions' => [
+ // first entry, set field:
+ [
+ 'reconciled' => $faker->boolean,
+ ],
+ ],
+ ],
+ ],
+ // tags
+ 'tags' => [
+ 'fields' => [
+ 'transactions' => [
+ // first entry, set field:
+ [
+ 'tags' => ['a', 'b', 'c'],
+ ],
+ ],
],
],
];
+ $extra = ['notes', 'internal_reference', 'bunq_payment_id', 'sepa_cc', 'sepa_ct_op', 'sepa_ct_id',
+ 'sepa_db', 'sepa_country', 'sepa_ep', 'sepa_ci', 'sepa_batch_id'];
+ foreach ($extra as $key) {
+ $set[$key] = [
+ 'fields' => [
+ 'transactions' => [
+ // first entry, set field:
+ [
+ $key => $faker->uuid,
+ ],
+ ],
+ ],
+ ];
+ }
+
+ return $set;
}
}
\ No newline at end of file
diff --git a/tests/Traits/TestHelpers.php b/tests/Traits/TestHelpers.php
index 7b0926a15d..8fa36b3df8 100644
--- a/tests/Traits/TestHelpers.php
+++ b/tests/Traits/TestHelpers.php
@@ -267,7 +267,7 @@ trait TestHelpers
}
// check if is array, if so we need something smart:
if (is_array($returnValue) && is_array($submission[$returnName])) {
- $this->compareArray($returnName, $submission[$returnName], $returnValue);
+ $this->compareArray($submission, $returnName, $submission[$returnName], $returnValue);
}
if (!is_array($returnValue) && !is_array($submission[$returnName])) {
$message = sprintf(
@@ -282,11 +282,12 @@ trait TestHelpers
}
/**
+ * @param array $fullOriginal
* @param string $key
* @param array $original
* @param array $returned
*/
- protected function compareArray(string $key, array $original, array $returned)
+ protected function compareArray(array $fullOriginal, string $key, array $original, array $returned)
{
$ignore = ['id', 'created_at', 'updated_at'];
foreach ($returned as $objectKey => $object) {
@@ -303,8 +304,10 @@ trait TestHelpers
}
if (array_key_exists($returnKey, $original[$objectKey])) {
$message = sprintf(
- 'Sub: sub-array "%s" returned value %s does not match sent X value %s.',
- $key, var_export($returnValue, true), var_export($original[$objectKey][$returnKey], true)
+ "Sub-array '%s' returned value %s does not match sent value %s.\n%s\n%s",
+ $key, var_export($returnValue, true), var_export($original[$objectKey][$returnKey], true),
+ json_encode($fullOriginal),
+ json_encode($returned),
);
$this->assertEquals($original[$objectKey][$returnKey], $returnValue, $message);
}