1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2019-2020 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Client\Html\Catalog\Home; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
private $context; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() : void |
19
|
|
|
{ |
20
|
|
|
$this->context = \TestHelperHtml::getContext(); |
21
|
|
|
$this->object = new \Aimeos\Client\Html\Catalog\Home\Standard( $this->context ); |
22
|
|
|
$this->object->setView( \TestHelperHtml::getView() ); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
protected function tearDown() : void |
27
|
|
|
{ |
28
|
|
|
unset( $this->object ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
public function testGetHeader() |
33
|
|
|
{ |
34
|
|
|
$tags = []; |
35
|
|
|
$expire = null; |
36
|
|
|
$view = $this->object->getView(); |
37
|
|
|
|
38
|
|
|
$this->object->setView( $this->object->addData( $view, $tags, $expire ) ); |
39
|
|
|
|
40
|
|
|
$this->assertEquals( '', $this->object->getHeader() ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
public function testGetHeaderException() |
45
|
|
|
{ |
46
|
|
|
$object = $this->getMockBuilder( \Aimeos\Client\Html\Catalog\Home\Standard::class ) |
47
|
|
|
->setConstructorArgs( array( $this->context, [] ) ) |
48
|
|
|
->setMethods( array( 'addData' ) ) |
49
|
|
|
->getMock(); |
50
|
|
|
|
51
|
|
|
$object->expects( $this->once() )->method( 'addData' ) |
52
|
|
|
->will( $this->throwException( new \RuntimeException() ) ); |
53
|
|
|
|
54
|
|
|
$object->setView( \TestHelperHtml::getView() ); |
55
|
|
|
|
56
|
|
|
$this->assertNull( $object->getHeader() ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
public function testGetBody() |
61
|
|
|
{ |
62
|
|
|
$tags = []; |
63
|
|
|
$expire = null; |
64
|
|
|
$view = $this->object->getView(); |
65
|
|
|
|
66
|
|
|
$this->object->setView( $this->object->addData( $view, $tags, $expire ) ); |
67
|
|
|
$output = $this->object->getBody(); |
68
|
|
|
|
69
|
|
|
$this->assertStringContainsString( 'root', $output ); |
70
|
|
|
$this->assertStringContainsString( 'categories', $output ); |
71
|
|
|
$this->assertStringContainsString( 'group', $output ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
public function testGetBodyHtmlException() |
76
|
|
|
{ |
77
|
|
|
$object = $this->getMockBuilder( \Aimeos\Client\Html\Catalog\Home\Standard::class ) |
78
|
|
|
->setConstructorArgs( array( $this->context, [] ) ) |
79
|
|
|
->setMethods( array( 'addData' ) ) |
80
|
|
|
->getMock(); |
81
|
|
|
|
82
|
|
|
$object->expects( $this->once() )->method( 'addData' ) |
83
|
|
|
->will( $this->throwException( new \Aimeos\Client\Html\Exception( 'test exception' ) ) ); |
84
|
|
|
|
85
|
|
|
$object->setView( \TestHelperHtml::getView() ); |
86
|
|
|
|
87
|
|
|
$this->assertStringContainsString( 'test exception', $object->getBody() ); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
|
91
|
|
|
public function testGetBodyFrontendException() |
92
|
|
|
{ |
93
|
|
|
$object = $this->getMockBuilder( \Aimeos\Client\Html\Catalog\Home\Standard::class ) |
94
|
|
|
->setConstructorArgs( array( $this->context, [] ) ) |
95
|
|
|
->setMethods( array( 'addData' ) ) |
96
|
|
|
->getMock(); |
97
|
|
|
|
98
|
|
|
$object->expects( $this->once() )->method( 'addData' ) |
99
|
|
|
->will( $this->throwException( new \Aimeos\Controller\Frontend\Exception( 'test exception' ) ) ); |
100
|
|
|
|
101
|
|
|
$object->setView( \TestHelperHtml::getView() ); |
102
|
|
|
|
103
|
|
|
$this->assertStringContainsString( 'test exception', $object->getBody() ); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
public function testGetBodyMShopException() |
108
|
|
|
{ |
109
|
|
|
$object = $this->getMockBuilder( \Aimeos\Client\Html\Catalog\Home\Standard::class ) |
110
|
|
|
->setConstructorArgs( array( $this->context, [] ) ) |
111
|
|
|
->setMethods( array( 'addData' ) ) |
112
|
|
|
->getMock(); |
113
|
|
|
|
114
|
|
|
$object->expects( $this->once() )->method( 'addData' ) |
115
|
|
|
->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
116
|
|
|
|
117
|
|
|
$object->setView( \TestHelperHtml::getView() ); |
118
|
|
|
|
119
|
|
|
$this->assertStringContainsString( 'test exception', $object->getBody() ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
public function testGetBodyException() |
124
|
|
|
{ |
125
|
|
|
$object = $this->getMockBuilder( \Aimeos\Client\Html\Catalog\Home\Standard::class ) |
126
|
|
|
->setConstructorArgs( array( $this->context, [] ) ) |
127
|
|
|
->setMethods( array( 'addData' ) ) |
128
|
|
|
->getMock(); |
129
|
|
|
|
130
|
|
|
$object->expects( $this->once() )->method( 'addData' ) |
131
|
|
|
->will( $this->throwException( new \RuntimeException( 'test exception' ) ) ); |
132
|
|
|
|
133
|
|
|
$object->setView( \TestHelperHtml::getView() ); |
134
|
|
|
|
135
|
|
|
$this->assertStringContainsString( 'A non-recoverable error occured', $object->getBody() ); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
public function testGetSubClientInvalid() |
140
|
|
|
{ |
141
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
142
|
|
|
$this->object->getSubClient( 'invalid', 'invalid' ); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
|
146
|
|
|
public function testGetSubClientInvalidName() |
147
|
|
|
{ |
148
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
149
|
|
|
$this->object->getSubClient( '$$$', '$$$' ); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
|
153
|
|
|
public function testProcess() |
154
|
|
|
{ |
155
|
|
|
$this->object->process(); |
156
|
|
|
|
157
|
|
|
$this->assertEmpty( $this->object->getView()->get( 'homeErrorList' ) ); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|