| @@ 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 | |
| @@ 168-179 (lines=12) @@ | ||
| 165 | * | |
| 166 | * @Then the JSON node :node should be equal to the string :text | |
| 167 | */ | |
| 168 | public function theJsonNodeShouldBeEqualToTheString($node, $text) | |
| 169 |     { | |
| 170 | $json = $this->getJson(); | |
| 171 | ||
| 172 | $actual = $this->inspector->evaluate($json, $node); | |
| 173 | ||
| 174 |         if ($actual !== $text) { | |
| 175 | throw new \Exception( | |
| 176 |                 sprintf('The node value is `%s`', json_encode($actual)) | |
| 177 | ); | |
| 178 | } | |
| 179 | } | |
| 180 | ||
| 181 | /** | |
| 182 | * Checks, that given JSON node is equal to the given number | |
| @@ 186-197 (lines=12) @@ | ||
| 183 | * | |
| 184 | * @Then the JSON node :node should be equal to the number :number | |
| 185 | */ | |
| 186 | public function theJsonNodeShouldBeEqualToTheNumber($node, $number) | |
| 187 |     { | |
| 188 | $json = $this->getJson(); | |
| 189 | ||
| 190 | $actual = $this->inspector->evaluate($json, $node); | |
| 191 | ||
| 192 |         if ($actual !== (float) $number && $actual !== (int) $number) { | |
| 193 | throw new \Exception( | |
| 194 |                 sprintf('The node value is `%s`', json_encode($actual)) | |
| 195 | ); | |
| 196 | } | |
| 197 | } | |
| 198 | ||
| 199 | /** | |
| 200 | * Checks, that given JSON node has N element(s) | |