Do not mock contact form in test
This commit is contained in:
parent
7959d142a7
commit
a56693d88f
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user