/
MinkExtraContext.php
77 lines (71 loc) · 2.08 KB
/
MinkExtraContext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace Behat\CommonContexts;
use Behat\Behat\Context\BehatContext,
Behat\Behat\Context\Step;
/**
* Provides some more steps/method for web application testing
*
* Please be aware that some drivers (such as Sahi) don't support
* http status code retrieval
*
* @author Geoffrey Bachelet <geoffrey.bachelet@gmail.com>
*/
class MinkExtraContext extends BehatContext
{
/**
* Checks that a page exists
*
* Provides an implementation-free but still reliable step to check a non-404 page.
*
* @Then /^page "(?P<page>[^"]+)" should exist$/
*/
public function pageShouldExist($page)
{
return array(
new Step\When('I go to "'.$page.'"'),
new Step\Then('the response status code should not be 404'),
);
}
/**
* Checks that a page does not exist
*
* Provides an implementation-free but still reliable step to check a 404 page.
*
* @Then /^page "(?P<page>[^"]+)" should not exist$/
*/
public function pageShouldNotExist($page)
{
return array(
new Step\When('I go to "'.$page.'"'),
new Step\Then('the response status code should be 404'),
);
}
/**
* Checks that you're not allowed to follow a link
*
* Provides an implementation-free but still reliable step to check a 403 page.
*
* @Then /^I should not be allowed to go to "(?P<page>[^"]+)"$/
*/
public function iShouldNotBeAllowedToGoTo($page)
{
return array(
new Step\When('I go to "'.$page.'"'),
new Step\Then('the response status code should be 403'),
);
}
/**
* Checks that you're allowed to follow a link
*
* Provides an implementation-free but still reliable step to check a 200 page.
*
* @Then /^I should be allowed to go to "(?P<page>[^"]+)"$/
*/
public function iShouldBeAllowedToGoTo($page)
{
return array(
new Step\When('I go to "'.$page.'"'),
new Step\Then('the response status code should be 200'),
);
}
}