From 3076318d059157b3d8656235c43d95b65c61444e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 23 Apr 2019 15:31:43 +0300 Subject: [PATCH] Fixed contact form tests --- tests/unit/models/ContactFormTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/models/ContactFormTest.php b/tests/unit/models/ContactFormTest.php index 86bbc2c..031d2bd 100644 --- a/tests/unit/models/ContactFormTest.php +++ b/tests/unit/models/ContactFormTest.php @@ -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'); }