2019-06-17 02:29:19 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace common\tests\unit\emails\templates;
|
|
|
|
|
|
|
|
use common\emails\RendererInterface;
|
|
|
|
use common\emails\templates\RegistrationEmail;
|
|
|
|
use common\emails\templates\RegistrationEmailParams;
|
|
|
|
use common\tests\unit\TestCase;
|
|
|
|
use yii\base\InvalidCallException;
|
|
|
|
use yii\mail\MailerInterface;
|
|
|
|
|
|
|
|
class RegistrationEmailTest extends TestCase {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
private RegistrationEmail $template;
|
2019-06-17 02:29:19 +05:30
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testParams(): void {
|
2019-06-17 02:29:19 +05:30
|
|
|
$this->template->setParams(new RegistrationEmailParams('mock-username', 'mock-code', 'mock-link'));
|
|
|
|
$params = $this->template->getParams();
|
|
|
|
$this->assertSame('mock-username', $params['username']);
|
|
|
|
$this->assertSame('mock-code', $params['code']);
|
|
|
|
$this->assertSame('mock-link', $params['link']);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testInvalidCallOfParams(): void {
|
2019-06-17 02:29:19 +05:30
|
|
|
$this->expectException(InvalidCallException::class);
|
|
|
|
$this->template->getParams();
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
protected function _before(): void {
|
2019-06-17 02:29:19 +05:30
|
|
|
parent::_before();
|
|
|
|
$mailer = $this->createMock(MailerInterface::class);
|
|
|
|
$renderer = $this->createMock(RendererInterface::class);
|
|
|
|
$this->template = new RegistrationEmail($mailer, $renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|