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

Commit

Permalink
Merge branch 'nicolasheraly-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed May 18, 2016
2 parents f9c0093 + 2e1e31c commit e4085a9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Context/JsonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ public function theJsonNodeShouldBeNull($node)
}
}

/**
* Checks, that given JSON node is not null.
*
* @Then the JSON node :node should not be null
*/
public function theJsonNodeShouldNotBeNull($name)
{
$this->not(function () use ($name) {
return $this->theJsonNodeShouldBeNull($name);
}, sprintf('The node %s should not be null', $name));
}

/**
* Checks, that given JSON node is true
*
Expand Down
15 changes: 15 additions & 0 deletions tests/features/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,18 @@ Feature: Testing JSONContext
And the JSON node "root[4]" should be equal to the number 1312
And the JSON node "root[4]" should be equal to the number 1312.0
And the JSON node "root[5]" should be equal to the number 1936.2

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 "one" should not be null
And the JSON node "one" should be false
And the JSON node "two" should not be null
And the JSON node "two" should be true
And the JSON node "three" should not be null
And the JSON node "three" should be equal to the string ""
And the JSON node "four" should not be null
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
7 changes: 7 additions & 0 deletions tests/fixtures/www/json/notnullvalues.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"one": false,
"two": true,
"three": "",
"four": "foo",
"five": 5
}

0 comments on commit e4085a9

Please sign in to comment.