| @@ 71-82 (lines=12) @@ | ||
| 68 | * |
|
| 69 | * @Then the JSON node :node should match :regexp |
|
| 70 | */ |
|
| 71 | public function theJsonNodeShouldMatch($node, $regexp) |
|
| 72 | { |
|
| 73 | $json = $this->getJson(); |
|
| 74 | ||
| 75 | $actual = $this->inspector->evaluate($json, $node); |
|
| 76 | ||
| 77 | if (!preg_match($regexp, $actual)) { |
|
| 78 | throw new \Exception( |
|
| 79 | sprintf("The node value is '%s'", json_encode($actual)) |
|
| 80 | ); |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Checks, that given JSON nodes are equal to givens values |
|
| @@ 167-178 (lines=12) @@ | ||
| 164 | * |
|
| 165 | * @Then the JSON node :node should be equal to the string :text |
|
| 166 | */ |
|
| 167 | public function theJsonNodeShouldBeEqualToTheString($node, $text) |
|
| 168 | { |
|
| 169 | $json = $this->getJson(); |
|
| 170 | ||
| 171 | $actual = $this->inspector->evaluate($json, $node); |
|
| 172 | ||
| 173 | if ($actual !== $text) { |
|
| 174 | throw new \Exception( |
|
| 175 | sprintf('The node value is `%s`', json_encode($actual)) |
|
| 176 | ); |
|
| 177 | } |
|
| 178 | } |
|
| 179 | ||
| 180 | /** |
|
| 181 | * Checks, that given JSON node is equal to the given number |
|
| @@ 185-196 (lines=12) @@ | ||
| 182 | * |
|
| 183 | * @Then the JSON node :node should be equal to the number :number |
|
| 184 | */ |
|
| 185 | public function theJsonNodeShouldBeEqualToTheNumber($node, $number) |
|
| 186 | { |
|
| 187 | $json = $this->getJson(); |
|
| 188 | ||
| 189 | $actual = $this->inspector->evaluate($json, $node); |
|
| 190 | ||
| 191 | if ($actual !== (float) $number && $actual !== (int) $number) { |
|
| 192 | throw new \Exception( |
|
| 193 | sprintf('The node value is `%s`', json_encode($actual)) |
|
| 194 | ); |
|
| 195 | } |
|
| 196 | } |
|
| 197 | ||
| 198 | /** |
|
| 199 | * Checks, that given JSON node has N element(s) |
|