| @@ 27-42 (lines=16) @@ | ||
| 24 | } |
|
| 25 | ||
| 26 | /** @Then the root should match: */ |
|
| 27 | public function root_should_match(PyStringNode $pattern) |
|
| 28 | { |
|
| 29 | $matcher = $this->factory->createMatcher(); |
|
| 30 | $body = (string) $this->getResponse()->getBody(); |
|
| 31 | ||
| 32 | if ($matcher->match($body, $pattern->getRaw())) { |
|
| 33 | return; |
|
| 34 | } |
|
| 35 | ||
| 36 | throw new InvalidArgumentException( |
|
| 37 | sprintf( |
|
| 38 | 'The json root does not match with the given pattern (error : %s)', |
|
| 39 | $matcher->getError() |
|
| 40 | ) |
|
| 41 | ); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** @Then in the json, :path should match: */ |
|
| 45 | public function path_should_match(string $path, PyStringNode $pattern) |
|
| @@ 28-44 (lines=17) @@ | ||
| 25 | } |
|
| 26 | ||
| 27 | /** @Then the response content should match :pattern */ |
|
| 28 | public function response_content_should_match(string $pattern) |
|
| 29 | { |
|
| 30 | $matcher = $this->factory->createMatcher(); |
|
| 31 | $content = (string) $this->getResponse()->getBody(); |
|
| 32 | ||
| 33 | if ($matcher->match($content, $pattern)) { |
|
| 34 | return; |
|
| 35 | } |
|
| 36 | ||
| 37 | throw new InvalidArgumentException( |
|
| 38 | sprintf( |
|
| 39 | 'The response does not match with the pattern "%s" (error : %s)', |
|
| 40 | $pattern, |
|
| 41 | $matcher->getError() |
|
| 42 | ) |
|
| 43 | ); |
|
| 44 | } |
|
| 45 | ||
| 46 | /** @Then the response content should not match :pattern */ |
|
| 47 | public function response_content_should_not_match(string $pattern) |
|
| @@ 47-63 (lines=17) @@ | ||
| 44 | } |
|
| 45 | ||
| 46 | /** @Then the response content should not match :pattern */ |
|
| 47 | public function response_content_should_not_match(string $pattern) |
|
| 48 | { |
|
| 49 | $matcher = $this->factory->createMatcher(); |
|
| 50 | $content = (string) $this->getResponse()->getBody(); |
|
| 51 | ||
| 52 | if (!$matcher->match($content, $pattern)) { |
|
| 53 | return; |
|
| 54 | } |
|
| 55 | ||
| 56 | throw new InvalidArgumentException( |
|
| 57 | sprintf( |
|
| 58 | 'The response matches with the pattern "%s" (error : %s)', |
|
| 59 | $pattern, |
|
| 60 | $matcher->getError() |
|
| 61 | ) |
|
| 62 | ); |
|
| 63 | } |
|
| 64 | ||
| 65 | /** @Then the response content should match: */ |
|
| 66 | public function response_content_should_match_PyString(PyStringNode $pattern) |
|
| @@ 66-76 (lines=11) @@ | ||
| 63 | } |
|
| 64 | ||
| 65 | /** @Then the response content should match: */ |
|
| 66 | public function response_content_should_match_PyString(PyStringNode $pattern) |
|
| 67 | { |
|
| 68 | $matcher = $this->factory->createMatcher(); |
|
| 69 | $content = (string) $this->getResponse()->getBody(); |
|
| 70 | ||
| 71 | if ($matcher->match($content, $pattern)) { |
|
| 72 | return; |
|
| 73 | } |
|
| 74 | ||
| 75 | throw new InvalidArgumentException($matcher->getError()); |
|
| 76 | } |
|
| 77 | ||
| 78 | /** @Then the response content should match: */ |
|
| 79 | public function response_content_should_not_match_PyString(PyStringNode $pattern) |
|
| @@ 79-89 (lines=11) @@ | ||
| 76 | } |
|
| 77 | ||
| 78 | /** @Then the response content should match: */ |
|
| 79 | public function response_content_should_not_match_PyString(PyStringNode $pattern) |
|
| 80 | { |
|
| 81 | $matcher = $this->factory->createMatcher(); |
|
| 82 | $content = (string) $this->getResponse()->getBody(); |
|
| 83 | ||
| 84 | if (!$matcher->match($content, $pattern)) { |
|
| 85 | return; |
|
| 86 | } |
|
| 87 | ||
| 88 | throw new InvalidArgumentException($matcher->getError()); |
|
| 89 | } |
|
| 90 | } |
|
| 91 | ||