Skip to content

Commit

Permalink
forgot about php
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp committed Feb 16, 2024
1 parent 0ee1051 commit 47deabf
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions templates/php/tests/requests/requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,17 @@ class {{clientPrefix}}Test extends TestCase implements HttpClientInterface
{{#hasE2E}}
protected function union($expected, $received)
{
$res = [];
foreach ($expected as $k => $v) {
if (isset($received[$k])) {
if (is_array($v)) {
$res[$k] = $this->union($v, $received[$k]);
} elseif (is_array($v)) {
if (!isset($res[$k])) {
$res[$k] = [];
}

foreach ($v as $iv => $v) {
$res[$k][] = $this->union($v, $received[$k][$iv]);
}
} else {
$res[$k] = $received[$k];
}
if (is_array($expected)) {
$res = [];
// array and object are the same thing in PHP (magic ✨)
foreach ($expected as $k => $v) {
$res[$k] = $this->union($v, $received[$k]);
}
}

return $res;
return $res;
}

return $received;
}
{{/hasE2E}}

Expand Down Expand Up @@ -193,4 +183,4 @@ class {{clientPrefix}}Test extends TestCase implements HttpClientInterface
}
{{/tests}}
{{/blocksRequests}}
}
}

0 comments on commit 47deabf

Please # to comment.