1 | <?php |
||
12 | class EmailContext extends RawEmailContext |
||
13 | { |
||
14 | const PARSE_STRING = '/^(.+?)$/i'; |
||
15 | |||
16 | private $originalMailSystem = [ |
||
17 | 'default-system' => 'DefaultMailSystem', |
||
18 | ]; |
||
19 | |||
20 | /** |
||
21 | * @example |
||
22 | * I check that email for "[email protected]" was sent |
||
23 | * |
||
24 | * @param string $to |
||
25 | * Recipient. |
||
26 | * |
||
27 | * @throws \RuntimeException |
||
28 | * When any message was not sent. |
||
29 | * |
||
30 | * @Given /^(?:|I )check that email for "([^"]*)" was sent$/ |
||
31 | */ |
||
32 | public function wasSent($to) |
||
36 | |||
37 | /** |
||
38 | * @example |
||
39 | * I check that email for "[email protected]" contains: |
||
40 | * | subject | New email letter | |
||
41 | * | body | The body of letter | |
||
42 | * I also check that email contains: |
||
43 | * | from | [email protected] | |
||
44 | * |
||
45 | * @param string $to |
||
46 | * Recipient. |
||
47 | * @param TableNode $values |
||
48 | * Left column - is a header key, right - value. |
||
49 | * |
||
50 | * @throws \RuntimeException |
||
51 | * When any message was not sent. |
||
52 | * @throws \InvalidArgumentException |
||
53 | * @throws \RuntimeException |
||
54 | * |
||
55 | * @Given /^(?:|I )check that email for "([^"]*)" contains:$/ |
||
56 | */ |
||
57 | public function contains($to, TableNode $values) |
||
73 | |||
74 | /** |
||
75 | * @param string $link |
||
76 | * Link text or value of "href" attribute. |
||
77 | * @param string $to |
||
78 | * Try to find in specific email. |
||
79 | * |
||
80 | * @Given /^(?:|I )click on link "([^"]*)" in email(?:| that was sent on "([^"]*)")$/ |
||
81 | */ |
||
82 | public function clickLink($link, $to = '') |
||
83 | { |
||
84 | foreach ($this->getEmailMessages($to) as $message) { |
||
85 | if (!isset($message['links'][$link]) && isset($message['links'])) { |
||
86 | $link = array_search($link, $message['links']); |
||
87 | } |
||
88 | |||
89 | if (isset($message['links'][$link])) { |
||
90 | $this->visitPath($message['links'][$link]); |
||
91 | } |
||
92 | } |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @param string $to |
||
97 | * |
||
98 | * @throws \Exception |
||
99 | * When parameter "parse_mail_callback" was not specified. |
||
100 | * @throws \InvalidArgumentException |
||
101 | * When parameter "parse_mail_callback" is not callable. |
||
102 | * @throws NoSuchElement |
||
103 | * When "Log in" button cannot be found on the page. |
||
104 | * @throws \RuntimeException |
||
105 | * When credentials cannot be parsed or does not exist. |
||
106 | * |
||
107 | * @Given /^(?:|I )login with credentials that was sent on (?:"([^"]*)"|email)$/ |
||
108 | */ |
||
109 | public function loginWithCredentialsThatWasSentByEmail($to = '') |
||
190 | |||
191 | /** |
||
192 | * @BeforeScenario @email&&@api&&~@imap |
||
193 | */ |
||
194 | public function beforeScenarioEmailApi() |
||
209 | |||
210 | /** |
||
211 | * @AfterScenario @email&&@api&&~@imap |
||
212 | */ |
||
213 | public function afterScenarioEmailApi() |
||
223 | |||
224 | /** |
||
225 | * @BeforeScenario @email&&@imap |
||
226 | */ |
||
227 | public function beforeScenarioEmailImap() |
||
242 | |||
243 | /** |
||
244 | * @AfterScenario @email&&@imap |
||
245 | */ |
||
246 | public function afterScenarioEmailImap() |
||
250 | } |
||
251 |