diff --git a/tests/unit/models/ContactFormTest.php b/tests/unit/models/ContactFormTest.php index 0744487..93313e4 100644 --- a/tests/unit/models/ContactFormTest.php +++ b/tests/unit/models/ContactFormTest.php @@ -7,7 +7,6 @@ use yii\mail\MessageInterface; class ContactFormTest extends \Codeception\Test\Unit { - private $model; /** * @var \UnitTester */ @@ -15,23 +14,17 @@ class ContactFormTest extends \Codeception\Test\Unit public function testEmailIsSentOnContact() { - /** @var ContactForm $model */ - $this->model = $this->getMockBuilder('app\models\ContactForm') - ->setMethods(['validate']) - ->getMock(); + $model = new ContactForm(); - $this->model->expects($this->once()) - ->method('validate') - ->willReturn(true); - - $this->model->attributes = [ + $model->attributes = [ 'name' => 'Tester', 'email' => 'tester@example.com', 'subject' => 'very important letter subject', 'body' => 'body of current message', + 'verifyCode' => 'testme', ]; - expect_that($this->model->contact('admin@example.com')); + expect_that($model->contact('admin@example.com')); // using Yii2 module actions to check email was sent $this->tester->seeEmailIsSent();