| @@ 138-149 (lines=12) @@ | ||
| 135 | * |
|
| 136 | * @Then the JSON node :node should be equal to the string :text |
|
| 137 | */ |
|
| 138 | public function theJsonNodeShouldBeEqualToTheString($node, $text) |
|
| 139 | { |
|
| 140 | $json = $this->getJson(); |
|
| 141 | ||
| 142 | $actual = $this->inspector->evaluate($json, $node); |
|
| 143 | ||
| 144 | if ($actual !== $text) { |
|
| 145 | throw new \Exception( |
|
| 146 | sprintf('The node value is `%s`', json_encode($actual)) |
|
| 147 | ); |
|
| 148 | } |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * Checks, that given JSON node is equal to the given number |
|
| @@ 156-167 (lines=12) @@ | ||
| 153 | * |
|
| 154 | * @Then the JSON node :node should be equal to the number :number |
|
| 155 | */ |
|
| 156 | public function theJsonNodeShouldBeEqualToTheNumber($node, $number) |
|
| 157 | { |
|
| 158 | $json = $this->getJson(); |
|
| 159 | ||
| 160 | $actual = $this->inspector->evaluate($json, $node); |
|
| 161 | ||
| 162 | if ($actual !== (float) $number && $actual !== (int) $number) { |
|
| 163 | throw new \Exception( |
|
| 164 | sprintf('The node value is `%s`', json_encode($actual)) |
|
| 165 | ); |
|
| 166 | } |
|
| 167 | } |
|
| 168 | ||
| 169 | /** |
|
| 170 | * Checks, that given JSON node has N element(s) |
|