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
|
class ContactFormTest extends \Codeception\Test\Unit
|
||||||
{
|
{
|
||||||
private $model;
|
|
||||||
/**
|
/**
|
||||||
* @var \UnitTester
|
* @var \UnitTester
|
||||||
*/
|
*/
|
||||||
@ -15,23 +14,17 @@ class ContactFormTest extends \Codeception\Test\Unit
|
|||||||
|
|
||||||
public function testEmailIsSentOnContact()
|
public function testEmailIsSentOnContact()
|
||||||
{
|
{
|
||||||
/** @var ContactForm $model */
|
$model = new ContactForm();
|
||||||
$this->model = $this->getMockBuilder('app\models\ContactForm')
|
|
||||||
->setMethods(['validate'])
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$this->model->expects($this->once())
|
$model->attributes = [
|
||||||
->method('validate')
|
|
||||||
->willReturn(true);
|
|
||||||
|
|
||||||
$this->model->attributes = [
|
|
||||||
'name' => 'Tester',
|
'name' => 'Tester',
|
||||||
'email' => 'tester@example.com',
|
'email' => 'tester@example.com',
|
||||||
'subject' => 'very important letter subject',
|
'subject' => 'very important letter subject',
|
||||||
'body' => 'body of current message',
|
'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
|
// using Yii2 module actions to check email was sent
|
||||||
$this->tester->seeEmailIsSent();
|
$this->tester->seeEmailIsSent();
|
||||||
|
Loading…
Reference in New Issue
Block a user