/
maxavangard
/
KTC
Обзор
Документация
Войти
/
maxavangard
/
KTC
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/Unit/Models/ContactFormTest.php
42 строки
1 KB
Avangartd
first_commit
28 июн 2026, 18:48
28 июн 2026, 18:48
f36fb03
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace app\tests\Unit\Models; use app\models\ContactForm; use Yii; use yii\mail\MessageInterface; final class ContactFormTest extends \Codeception\Test\Unit { public mixed $tester = null; public function testEmailIsSentOnContact() { $model = new ContactForm(); $model->attributes = [ 'name' => 'Tester', 'email' => 'tester@example.com', 'subject' => 'very important letter subject', 'body' => 'body of current message', 'verifyCode' => 'testme', ]; verify($model->contact(Yii::$app->mailer, 'admin@example.com', 'noreply@example.com', 'Example.com mailer'))->notEmpty(); // using Yii2 module actions to check email was sent $this->tester->seeEmailIsSent(); /** @var MessageInterface $emailMessage */ $emailMessage = $this->tester->grabLastSentEmail(); verify($emailMessage)->instanceOf('yii\mail\MessageInterface'); verify($emailMessage->getTo())->arrayHasKey('admin@example.com'); verify($emailMessage->getFrom())->arrayHasKey('noreply@example.com'); verify($emailMessage->getReplyTo())->arrayHasKey('tester@example.com'); verify($emailMessage->getSubject())->equals('very important letter subject'); verify($emailMessage->toString())->stringContainsString('body of current message'); } }