Fixed contact form tests
This commit is contained in:
parent
e38c34a935
commit
3076318d05
@ -2,6 +2,9 @@
|
||||
|
||||
namespace tests\unit\models;
|
||||
|
||||
use app\models\ContactForm;
|
||||
use yii\mail\MessageInterface;
|
||||
|
||||
class ContactFormTest extends \Codeception\Test\Unit
|
||||
{
|
||||
private $model;
|
||||
@ -19,7 +22,7 @@ class ContactFormTest extends \Codeception\Test\Unit
|
||||
|
||||
$this->model->expects($this->once())
|
||||
->method('validate')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
$this->model->attributes = [
|
||||
'name' => 'Tester',
|
||||
@ -33,10 +36,12 @@ class ContactFormTest extends \Codeception\Test\Unit
|
||||
// using Yii2 module actions to check email was sent
|
||||
$this->tester->seeEmailIsSent();
|
||||
|
||||
/** @var MessageInterface $emailMessage */
|
||||
$emailMessage = $this->tester->grabLastSentEmail();
|
||||
expect('valid email is sent', $emailMessage)->isInstanceOf('yii\mail\MessageInterface');
|
||||
expect($emailMessage->getTo())->hasKey('admin@example.com');
|
||||
expect($emailMessage->getFrom())->hasKey('tester@example.com');
|
||||
expect($emailMessage->getFrom())->hasKey('noreply@example.com');
|
||||
expect($emailMessage->getReplyTo())->hasKey('tester@example.com');
|
||||
expect($emailMessage->getSubject())->equals('very important letter subject');
|
||||
expect($emailMessage->toString())->contains('body of current message');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user