2019-06-17 02:29:19 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace common\tests\unit\emails\templates;
|
|
|
|
|
|
|
|
use common\emails\templates\ConfirmNewEmail;
|
|
|
|
use common\tests\unit\TestCase;
|
|
|
|
use yii\base\InvalidCallException;
|
|
|
|
use yii\mail\MailerInterface;
|
|
|
|
|
|
|
|
class ConfirmNewEmailTest extends TestCase {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
private ConfirmNewEmail $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->setUsername('mock-username');
|
|
|
|
$this->template->setKey('mock-key');
|
|
|
|
$params = $this->template->getParams();
|
|
|
|
$this->assertSame('mock-username', $params['username']);
|
|
|
|
$this->assertSame('mock-key', $params['key']);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider getInvalidCallsCases
|
|
|
|
*/
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testInvalidCallOfParams(?string $username, ?string $key): void {
|
2019-06-17 02:29:19 +05:30
|
|
|
$this->expectException(InvalidCallException::class);
|
|
|
|
$username !== null && $this->template->setUsername($username);
|
|
|
|
$key !== null && $this->template->setKey($key);
|
|
|
|
$this->template->getParams();
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function getInvalidCallsCases(): iterable {
|
2019-06-17 02:29:19 +05:30
|
|
|
yield [null, null];
|
|
|
|
yield ['value', null];
|
|
|
|
yield [null, 'value'];
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
$this->template = new ConfirmNewEmail($mailer);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|