1
|
|
|
<?php |
2
|
|
|
namespace AcMailerTest\Options; |
3
|
|
|
|
4
|
|
|
use AcMailer\Options\TemplateOptions; |
5
|
|
|
use PHPUnit_Framework_TestCase as TestCase; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class TemplateOptionsTest |
9
|
|
|
* @author |
10
|
|
|
* @link |
11
|
|
|
*/ |
12
|
|
|
class TemplateOptionsTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var TemplateOptions |
16
|
|
|
*/ |
17
|
|
|
private $templateOptions; |
18
|
|
|
|
19
|
|
|
public function setUp() |
20
|
|
|
{ |
21
|
|
|
$this->templateOptions = new TemplateOptions(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function testDefaultTemplateOptionsValues() |
25
|
|
|
{ |
26
|
|
|
$this->assertEquals('ac-mailer/mail-templates/mail', $this->templateOptions->getPath()); |
27
|
|
|
$this->assertEquals([], $this->templateOptions->getParams()); |
28
|
|
|
$this->assertCount(0, $this->templateOptions->getParams()); |
29
|
|
|
$this->assertEquals([], $this->templateOptions->getChildren()); |
30
|
|
|
$this->assertCount(0, $this->templateOptions->getChildren()); |
31
|
|
|
$this->assertEquals([], $this->templateOptions->getDefaultLayout()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testChildrenCastToTemplateOptions() |
35
|
|
|
{ |
36
|
|
|
$children = [ |
37
|
|
|
'content' => [ |
38
|
|
|
'path' => 'ac-mailer/content', |
39
|
|
|
'params' => [], |
40
|
|
|
], |
41
|
|
|
'foo' => [ |
42
|
|
|
'path' => 'ac-mailer/foo', |
43
|
|
|
'params' => [], |
44
|
|
|
], |
45
|
|
|
'bar' => [ |
46
|
|
|
'path' => 'ac-mailer/bar', |
47
|
|
|
'params' => [], |
48
|
|
|
'children' => [ |
49
|
|
|
'nested' => [ |
50
|
|
|
'path' => 'ac-mailer/nested', |
51
|
|
|
'params' => [], |
52
|
|
|
] |
53
|
|
|
] |
54
|
|
|
] |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
$this->templateOptions->setChildren($children); |
58
|
|
|
$this->recursiveChildAssert($this->templateOptions->getChildren()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
private function recursiveChildAssert($children) |
62
|
|
|
{ |
63
|
|
|
/* @var TemplateOptions $child */ |
64
|
|
|
foreach ($children as $child) { |
65
|
|
|
$this->assertInstanceOf('AcMailer\Options\TemplateOptions', $child); |
66
|
|
|
$this->recursiveChildAssert($child->getChildren()); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function testDefaultLayout() |
71
|
|
|
{ |
72
|
|
|
$layoutConfig = [ |
73
|
|
|
'path' => 'foo/bar/baz', |
74
|
|
|
'params' => [ |
75
|
|
|
'foo' => 'bar' |
76
|
|
|
], |
77
|
|
|
'template_capture_to' => 'content' |
78
|
|
|
]; |
79
|
|
|
$this->assertSame($this->templateOptions, $this->templateOptions->setDefaultLayout($layoutConfig)); |
80
|
|
|
$this->assertEquals($layoutConfig, $this->templateOptions->getDefaultLayout()); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|