Conditions | 1 |
Paths | 1 |
Total Lines | 22 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function testSendEmail() |
||
18 | { |
||
19 | $model = new ContactForm(); |
||
20 | |||
21 | $model->attributes = [ |
||
22 | 'name' => 'Tester', |
||
23 | 'email' => '[email protected]', |
||
24 | 'subject' => 'very important letter subject', |
||
25 | 'body' => 'body of current message', |
||
26 | ]; |
||
27 | |||
28 | expect_that($model->sendEmail('[email protected]')); |
||
29 | |||
30 | // using Yii2 module actions to check email was sent |
||
31 | $this->tester->seeEmailIsSent(); |
||
32 | |||
33 | $emailMessage = $this->tester->grabLastSentEmail(); |
||
34 | expect('valid email is sent', $emailMessage)->isInstanceOf('yii\mail\MessageInterface'); |
||
35 | expect($emailMessage->getTo())->hasKey('[email protected]'); |
||
36 | expect($emailMessage->getFrom())->hasKey('[email protected]'); |
||
37 | expect($emailMessage->getSubject())->equals('very important letter subject'); |
||
38 | expect($emailMessage->toString())->contains('body of current message'); |
||
39 | } |
||
41 |