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'); }