You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.1 KiB

<?php
namespace yiiunit\framework\mail;
use yii\mail\ViewResolver;
use Yii;
use yiiunit\TestCase;
/**
* @group email
*/
class ViewResolverTest extends TestCase
{
/**
* @var string test email view path.
*/
protected $testViewPath = '@yiiunit/emails';
/**
* Data provider for [[testFindViewFile()]]
* @return array test data.
*/
public function dataProviderFindViewFile()
{
$alias = '@yiiunit';
$aliasPath = Yii::getAlias($alias);
$viewPath = Yii::getAlias($this->testViewPath);
return [
[
$alias . '/test',
$aliasPath . '/test.php',
],
[
$alias . '/test.tpl',
$aliasPath . '/test.tpl',
],
[
'contact/html',
$viewPath . '/contact/html.php',
],
[
'contact/html.tpl',
$viewPath . '/contact/html.tpl',
],
];
}
/**
* @dataProvider dataProviderFindViewFile
*
* @param string $view
* @param string $expectedFileName
*/
public function testFindViewFile($view, $expectedFileName)
{
$viewResolver = new ViewResolver();
$viewResolver->viewPath = $this->testViewPath;
$fileName = $viewResolver->findViewFile($view);
$this->assertEquals($expectedFileName, $fileName);
}
}