|
2 | 2 |
|
3 | 3 | namespace Behatch\Context; |
4 | 4 |
|
| 5 | +use Behat\Gherkin\Node\PyStringNode; |
| 6 | +use Behat\Gherkin\Node\TableNode; |
5 | 7 | use Behat\Mink\Exception\ExpectationException; |
6 | 8 | use Behatch\HttpCall\Request; |
7 | | -use Behat\Gherkin\Node\TableNode; |
8 | | -use Behat\Gherkin\Node\PyStringNode; |
9 | 9 |
|
10 | 10 | class RestContext extends BaseContext |
11 | 11 | { |
@@ -181,6 +181,33 @@ protected function theHeaderShouldExist($name) |
181 | 181 | return $this->request->getHttpHeader($name); |
182 | 182 | } |
183 | 183 |
|
| 184 | + /** |
| 185 | + * @Then the header :name should match :regex |
| 186 | + */ |
| 187 | + public function theHeaderShouldMatch($name, $regex) |
| 188 | + { |
| 189 | + $actual = $this->request->getHttpHeader($name); |
| 190 | + |
| 191 | + $this->assertEquals( |
| 192 | + 1, |
| 193 | + preg_match($regex, $actual), |
| 194 | + "The header '$name' should match '$regex', but it is: '$actual'" |
| 195 | + ); |
| 196 | + } |
| 197 | + |
| 198 | + /** |
| 199 | + * @Then the header :name should not match :regex |
| 200 | + */ |
| 201 | + public function theHeaderShouldNotMatch($name, $regex) |
| 202 | + { |
| 203 | + $this->not( |
| 204 | + function () use ($name, $regex) { |
| 205 | + $this->theHeaderShouldMatch($name, $regex); |
| 206 | + }, |
| 207 | + "The header '$name' should not match '$regex'" |
| 208 | + ); |
| 209 | + } |
| 210 | + |
184 | 211 | /** |
185 | 212 | * Checks, that the response header expire is in the future |
186 | 213 | * |
|
0 commit comments