Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
subrequests
Commits
7e5d58d8
Unverified
Commit
7e5d58d8
authored
Sep 16, 2017
by
Mateu Aguiló Bosch
Browse files
test(Replacements): Improve testing for the replacements
parent
e54d8e7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/src/Unit/JsonPathReplacerTest.php
View file @
7e5d58d8
...
...
@@ -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
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment