Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Commit c32976d

Browse files
Avoid bug with number when testing string
Fixes #263
1 parent cbda31e commit c32976d

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/Context/JsonContext.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ public function theJsonNodeShouldBeEqualToTheString($node, $text)
171171

172172
$actual = $this->inspector->evaluate($json, $node);
173173

174+
$text = (string) $text;
175+
174176
if ($actual !== $text) {
175177
throw new \Exception(
176178
sprintf('The node value is `%s`', json_encode($actual))

tests/features/json.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ Feature: Testing JSONContext
186186
And the JSON node "four" should be equal to the string "foo"
187187
And the JSON node "five" should not be null
188188
And the JSON node "five" should be equal to the number 5
189+
And the JSON node "six" should be equal to the string "44000"
189190

190191
Scenario: Json validation against swagger dump file
191192
Given I am on "/json/swaggerpartial.json"

tests/fixtures/www/json/notnullvalues.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"two": true,
44
"three": "",
55
"four": "foo",
6-
"five": 5
6+
"five": 5,
7+
"six": "44000"
78
}

0 commit comments

Comments
 (0)