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