| @@ 54-65 (lines=12) @@ | ||
| 51 | * |
|
| 52 | * @Then the JSON node :node should be equal to :text |
|
| 53 | */ |
|
| 54 | public function theJsonNodeShouldBeEqualTo($node, $text) |
|
| 55 | { |
|
| 56 | $json = $this->getJson(); |
|
| 57 | ||
| 58 | $actual = $this->inspector->evaluate($json, $node); |
|
| 59 | ||
| 60 | if ($actual != $text) { |
|
| 61 | throw new \Exception( |
|
| 62 | sprintf("The node value is '%s'", json_encode($actual)) |
|
| 63 | ); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Checks, that given JSON nodes are equal to givens values |
|
| @@ 159-170 (lines=12) @@ | ||
| 156 | * |
|
| 157 | * @Then the JSON node :node should be equal to the string :text |
|
| 158 | */ |
|
| 159 | public function theJsonNodeShouldBeEqualToTheString($node, $text) |
|
| 160 | { |
|
| 161 | $json = $this->getJson(); |
|
| 162 | ||
| 163 | $actual = $this->inspector->evaluate($json, $node); |
|
| 164 | ||
| 165 | if ($actual !== $text) { |
|
| 166 | throw new \Exception( |
|
| 167 | sprintf('The node value is `%s`', json_encode($actual)) |
|
| 168 | ); |
|
| 169 | } |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * Checks, that given JSON node is equal to the given number |
|
| @@ 177-188 (lines=12) @@ | ||
| 174 | * |
|
| 175 | * @Then the JSON node :node should be equal to the number :number |
|
| 176 | */ |
|
| 177 | public function theJsonNodeShouldBeEqualToTheNumber($node, $number) |
|
| 178 | { |
|
| 179 | $json = $this->getJson(); |
|
| 180 | ||
| 181 | $actual = $this->inspector->evaluate($json, $node); |
|
| 182 | ||
| 183 | if ($actual !== (float) $number && $actual !== (int) $number) { |
|
| 184 | throw new \Exception( |
|
| 185 | sprintf('The node value is `%s`', json_encode($actual)) |
|
| 186 | ); |
|
| 187 | } |
|
| 188 | } |
|
| 189 | ||
| 190 | /** |
|
| 191 | * Checks, that given JSON node has N element(s) |
|