summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateu Aguiló Bosch2017-09-16 14:36:50 +0200
committerMateu Aguiló Bosch2017-09-16 14:36:50 +0200
commit7e5d58d8ef2b05da11b0db6d11e5d7a2b04fb511 (patch)
tree8b073e26d3d0b2bd60390ed47f19a8ce267dc45c
parente54d8e7ba6b8ada8b8605506988a4c671fe5ca0e (diff)
test(Replacements): Improve testing for the replacements
-rw-r--r--tests/src/Unit/JsonPathReplacerTest.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/src/Unit/JsonPathReplacerTest.php b/tests/src/Unit/JsonPathReplacerTest.php
index 59fb7f0..75580fd 100644
--- a/tests/src/Unit/JsonPathReplacerTest.php
+++ b/tests/src/Unit/JsonPathReplacerTest.php
@@ -29,7 +29,7 @@ class JsonPathReplacerTest extends UnitTestCase {
public function testReplaceBatch() {
$batch = $responses = [];
$batch[] = new Subrequest([
- 'uri' => '/ipsum/{{foo.body@$.things[*]}}',
+ 'uri' => '/ipsum/{{foo.body@$.things[*]}}/{{bar.body@$.things[*]}}',
'action' => 'sing',
'requestId' => 'oop',
'headers' => [],
@@ -49,12 +49,27 @@ class JsonPathReplacerTest extends UnitTestCase {
$response = Response::create('{"things":["what","keep","talking"],"stuff":42}');
$response->headers->set('Content-ID', '<foo>');
$responses[] = $response;
+ $response = Response::create('{"things":["the","plane","is"],"stuff":"delayed"}');
+ $response->headers->set('Content-ID', '<bar>');
+ $responses[] = $response;
$actual = $this->sut->replaceBatch($batch, $responses);
- $this->assertCount(4, $actual);
+ $this->assertCount(10, $actual);
$paths = array_map(function (Subrequest $subrequest) {
return $subrequest->uri;
}, $actual);
- $this->assertEquals(['/ipsum/what', '/ipsum/keep', '/ipsum/talking', '/dolor/42'], $paths);
+ $expected_paths = [
+ '/ipsum/what/the',
+ '/ipsum/keep/the',
+ '/ipsum/talking/the',
+ '/ipsum/what/plane',
+ '/ipsum/keep/plane',
+ '/ipsum/talking/plane',
+ '/ipsum/what/is',
+ '/ipsum/keep/is',
+ '/ipsum/talking/is',
+ '/dolor/42',
+ ];
+ $this->assertEquals($expected_paths, $paths);
$this->assertEquals(['answer' => 42], $actual[0]->body);
}