|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2021 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Client\Html\Cms\Page; |
|
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->context->getLocale()->setLanguageId( 'en' ); |
|
22
|
|
|
|
|
23
|
|
|
$this->object = new \Aimeos\Client\Html\Cms\Page\Standard( $this->context ); |
|
24
|
|
|
$this->object->setView( \TestHelperHtml::getView() ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
protected function tearDown() : void |
|
29
|
|
|
{ |
|
30
|
|
|
unset( $this->object ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
public function testGetHeader() |
|
35
|
|
|
{ |
|
36
|
|
|
$view = $this->object->getView(); |
|
37
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, array( 'path' => '/contact' ) ); |
|
38
|
|
|
$view->addHelper( 'param', $helper ); |
|
39
|
|
|
|
|
40
|
|
|
$tags = []; |
|
41
|
|
|
$expire = null; |
|
42
|
|
|
|
|
43
|
|
|
$this->object->setView( $this->object->addData( $this->object->getView(), $tags, $expire ) ); |
|
44
|
|
|
$output = $this->object->getHeader(); |
|
45
|
|
|
|
|
46
|
|
|
$this->assertStringContainsString( '<title>Contact page</title>', $output ); |
|
47
|
|
|
$this->assertEquals( null, $expire ); |
|
48
|
|
|
$this->assertEquals( 2, count( $tags ) ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testGetHeaderException() |
|
53
|
|
|
{ |
|
54
|
|
|
$mock = $this->getMockBuilder( \Aimeos\Client\Html\Cms\Page\Standard::class ) |
|
55
|
|
|
->setConstructorArgs( [$this->context] ) |
|
56
|
|
|
->setMethods( array( 'addData' ) ) |
|
57
|
|
|
->getMock(); |
|
58
|
|
|
|
|
59
|
|
|
$view = $this->object->getView(); |
|
60
|
|
|
$view->addHelper( 'param', new \Aimeos\MW\View\Helper\Param\Standard( $view, ['path' => 'invalid'] ) ); |
|
61
|
|
|
$mock->setView( $view ); |
|
62
|
|
|
|
|
63
|
|
|
$mock->expects( $this->once() )->method( 'addData' ) |
|
64
|
|
|
->will( $this->throwException( new \RuntimeException() ) ); |
|
65
|
|
|
|
|
66
|
|
|
$mock->getHeader(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
public function testGetBody() |
|
71
|
|
|
{ |
|
72
|
|
|
$view = $this->object->getView(); |
|
73
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, array( 'path' => '/contact' ) ); |
|
74
|
|
|
$view->addHelper( 'param', $helper ); |
|
75
|
|
|
|
|
76
|
|
|
$tags = []; |
|
77
|
|
|
$expire = null; |
|
78
|
|
|
|
|
79
|
|
|
$this->object->setView( $this->object->addData( $view, $tags, $expire ) ); |
|
80
|
|
|
$output = $this->object->getBody(); |
|
81
|
|
|
|
|
82
|
|
|
$this->assertStringStartsWith( '<section class="aimeos cms-page"', $output ); |
|
83
|
|
|
$this->assertStringContainsString( '<h1>Hello!</h1>', $output ); |
|
84
|
|
|
|
|
85
|
|
|
$this->assertEquals( null, $expire ); |
|
86
|
|
|
$this->assertEquals( 2, count( $tags ) ); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
public function testGetBodyClientHtmlException() |
|
91
|
|
|
{ |
|
92
|
|
|
$mock = $this->getMockBuilder( \Aimeos\Client\Html\Cms\Page\Standard::class ) |
|
93
|
|
|
->setConstructorArgs( [$this->context] ) |
|
94
|
|
|
->setMethods( array( 'addData' ) ) |
|
95
|
|
|
->getMock(); |
|
96
|
|
|
|
|
97
|
|
|
$view = $this->object->getView(); |
|
98
|
|
|
$view->addHelper( 'param', new \Aimeos\MW\View\Helper\Param\Standard( $view, ['path' => 'invalid'] ) ); |
|
99
|
|
|
$mock->setView( $view ); |
|
100
|
|
|
|
|
101
|
|
|
$mock->expects( $this->once() )->method( 'addData' ) |
|
102
|
|
|
->will( $this->throwException( new \Aimeos\Client\Html\Exception() ) ); |
|
103
|
|
|
|
|
104
|
|
|
$mock->getBody(); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
public function testGetBodyControllerFrontendException() |
|
109
|
|
|
{ |
|
110
|
|
|
$mock = $this->getMockBuilder( \Aimeos\Client\Html\Cms\Page\Standard::class ) |
|
111
|
|
|
->setConstructorArgs( [$this->context] ) |
|
112
|
|
|
->setMethods( array( 'addData' ) ) |
|
113
|
|
|
->getMock(); |
|
114
|
|
|
|
|
115
|
|
|
$view = $this->object->getView(); |
|
116
|
|
|
$view->addHelper( 'param', new \Aimeos\MW\View\Helper\Param\Standard( $view, ['path' => 'invalid'] ) ); |
|
117
|
|
|
$mock->setView( $view ); |
|
118
|
|
|
|
|
119
|
|
|
$mock->expects( $this->once() )->method( 'addData' ) |
|
120
|
|
|
->will( $this->throwException( new \Aimeos\Controller\Frontend\Exception() ) ); |
|
121
|
|
|
|
|
122
|
|
|
$mock->getBody(); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
|
|
126
|
|
|
public function testGetBodyMShopException() |
|
127
|
|
|
{ |
|
128
|
|
|
$mock = $this->getMockBuilder( \Aimeos\Client\Html\Cms\Page\Standard::class ) |
|
129
|
|
|
->setConstructorArgs( [$this->context] ) |
|
130
|
|
|
->setMethods( array( 'addData' ) ) |
|
131
|
|
|
->getMock(); |
|
132
|
|
|
|
|
133
|
|
|
$view = $this->object->getView(); |
|
134
|
|
|
$view->addHelper( 'param', new \Aimeos\MW\View\Helper\Param\Standard( $view, ['path' => 'invalid'] ) ); |
|
135
|
|
|
$mock->setView( $view ); |
|
136
|
|
|
|
|
137
|
|
|
$mock->expects( $this->once() )->method( 'addData' ) |
|
138
|
|
|
->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
139
|
|
|
|
|
140
|
|
|
$mock->getBody(); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
|
|
144
|
|
|
public function testGetBodyException() |
|
145
|
|
|
{ |
|
146
|
|
|
$mock = $this->getMockBuilder( \Aimeos\Client\Html\Cms\Page\Standard::class ) |
|
147
|
|
|
->setConstructorArgs( [$this->context] ) |
|
148
|
|
|
->setMethods( array( 'addData' ) ) |
|
149
|
|
|
->getMock(); |
|
150
|
|
|
|
|
151
|
|
|
$view = $this->object->getView(); |
|
152
|
|
|
$view->addHelper( 'param', new \Aimeos\MW\View\Helper\Param\Standard( $view, ['path' => 'invalid'] ) ); |
|
153
|
|
|
$mock->setView( $view ); |
|
154
|
|
|
|
|
155
|
|
|
$mock->expects( $this->once() )->method( 'addData' ) |
|
156
|
|
|
->will( $this->throwException( new \RuntimeException() ) ); |
|
157
|
|
|
|
|
158
|
|
|
$mock->getBody(); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
|
|
162
|
|
|
public function testGetSubClientInvalid() |
|
163
|
|
|
{ |
|
164
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
|
165
|
|
|
$this->object->getSubClient( 'invalid', 'invalid' ); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
|
|
169
|
|
|
public function testGetSubClientInvalidName() |
|
170
|
|
|
{ |
|
171
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
|
172
|
|
|
$this->object->getSubClient( '$$$', '$$$' ); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
public function testProcess() |
|
177
|
|
|
{ |
|
178
|
|
|
$this->object->process(); |
|
179
|
|
|
|
|
180
|
|
|
$this->assertEmpty( $this->object->getView()->get( 'pageErrorList' ) ); |
|
181
|
|
|
} |
|
182
|
|
|
} |
|
183
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths