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

Avoid bug with number when testing string #265

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Context/JsonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public function theJsonNodeShouldBeEqualToTheString($node, $text)

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

$text = (string) $text;

if ($actual !== $text) {
throw new \Exception(
sprintf('The node value is `%s`', json_encode($actual))
Expand Down
3 changes: 2 additions & 1 deletion tests/features/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Feature: Testing JSONContext
Scenario: Check not null values
Given I am on "/json/notnullvalues.json"
Then the response should be in JSON
And the JSON node '' should have 5 elements
And the JSON node '' should have 6 elements
And the JSON node "one" should not be null
And the JSON node "one" should be false
And the JSON node "two" should not be null
Expand All @@ -186,6 +186,7 @@ Feature: Testing JSONContext
And the JSON node "four" should be equal to the string "foo"
And the JSON node "five" should not be null
And the JSON node "five" should be equal to the number 5
And the JSON node "six" should be equal to the string "44000"

Scenario: Json validation against swagger dump file
Given I am on "/json/swaggerpartial.json"
Expand Down
3 changes: 2 additions & 1 deletion tests/features/ru/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
Сценарий: Тестирование не-null значений
Пусть я на странице "/json/notnullvalues.json"
Тогда ответ должен быть в JSON
И узел JSON '' должен содержать 5 элементов
И узел JSON '' должен содержать 6 элементов
И узел JSON "one" не должен быть null
И узел JSON "one" должен быть ложью
И узел JSON "two" не должен быть null
Expand All @@ -187,3 +187,4 @@
И узел JSON "four" должен быть равен строке "foo"
И узел JSON "five" не должен быть null
И узел JSON "five" должен быть равен числу 5
И узел JSON "six" должен быть равен строке "44000"
3 changes: 2 additions & 1 deletion tests/fixtures/www/json/notnullvalues.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"two": true,
"three": "",
"four": "foo",
"five": 5
"five": 5,
"six": "44000"
}