|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
namespace Aimeos\Client\Html\Checkout\Standard\Summary; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
private $object; |
|
16
|
|
|
private $context; |
|
17
|
|
|
private $view; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
protected function setUp() : void |
|
21
|
|
|
{ |
|
22
|
|
|
$this->view = \TestHelperHtml::view(); |
|
23
|
|
|
$this->context = \TestHelperHtml::context(); |
|
24
|
|
|
|
|
25
|
|
|
$this->view = \TestHelperHtml::view(); |
|
26
|
|
|
$this->view->standardBasket = \Aimeos\MShop::create( $this->context, 'order/base' )->create(); |
|
27
|
|
|
|
|
28
|
|
|
$this->object = new \Aimeos\Client\Html\Checkout\Standard\Summary\Standard( $this->context ); |
|
29
|
|
|
$this->object->setView( $this->view ); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
protected function tearDown() : void |
|
34
|
|
|
{ |
|
35
|
|
|
unset( $this->object, $this->context, $this->view ); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
public function testBody() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->view = \TestHelperHtml::view(); |
|
42
|
|
|
$this->view->standardStepActive = 'summary'; |
|
43
|
|
|
$this->view->standardBasket = $this->getBasket(); |
|
44
|
|
|
$this->view->standardSteps = array( 'before', 'summary' ); |
|
45
|
|
|
$this->object->setView( $this->object->data( $this->view ) ); |
|
46
|
|
|
|
|
47
|
|
|
$output = $this->object->body(); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertStringStartsWith( '<section class="checkout-standard-summary common-summary">', $output ); |
|
50
|
|
|
$this->assertStringContainsString( '<div class="checkout-standard-summary-option', $output ); |
|
51
|
|
|
$this->assertStringContainsString( '<div class="checkout-standard-summary-option-account', $output ); |
|
52
|
|
|
$this->assertStringContainsString( '<div class="checkout-standard-summary-option-terms', $output ); |
|
53
|
|
|
|
|
54
|
|
|
$this->assertStringContainsString( 'Example company', $output ); |
|
55
|
|
|
$this->assertStringContainsString( 'unitpaymentlabel', $output ); |
|
56
|
|
|
$this->assertStringContainsString( 'Unittest service name', $output ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
public function testBodyDetail() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->view = \TestHelperHtml::view(); |
|
63
|
|
|
$this->view->standardStepActive = 'summary'; |
|
64
|
|
|
$this->view->standardBasket = $this->getBasket(); |
|
65
|
|
|
$this->object->setView( $this->object->data( $this->view ) ); |
|
66
|
|
|
|
|
67
|
|
|
$output = $this->object->body(); |
|
68
|
|
|
$this->assertStringContainsString( '<div class="common-summary-detail', $output ); |
|
69
|
|
|
$this->assertRegExp( '#<div class="tax.*<div class="price.*10.84 EUR</div>#smU', $output ); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
public function testBodyOtherStep() |
|
74
|
|
|
{ |
|
75
|
|
|
$output = $this->object->body(); |
|
76
|
|
|
$this->assertEquals( '', $output ); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
public function testGetSubClientInvalid() |
|
81
|
|
|
{ |
|
82
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
|
83
|
|
|
$this->object->getSubClient( 'invalid', 'invalid' ); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
public function testGetSubClientInvalidName() |
|
88
|
|
|
{ |
|
89
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
|
90
|
|
|
$this->object->getSubClient( '$$$', '$$$' ); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
public function testInit() |
|
95
|
|
|
{ |
|
96
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, array( 'cs_order' => 1 ) ); |
|
97
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
98
|
|
|
$this->object->setView( $this->view ); |
|
99
|
|
|
|
|
100
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
|
101
|
|
|
$this->object->init(); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
public function testInitComment() |
|
106
|
|
|
{ |
|
107
|
|
|
$controller = \Aimeos\Controller\Frontend\Basket\Factory::create( $this->context ); |
|
108
|
|
|
|
|
109
|
|
|
$this->view = \TestHelperHtml::view(); |
|
110
|
|
|
$this->view->standardBasket = $controller->get(); |
|
111
|
|
|
|
|
112
|
|
|
$param = array( 'cs_comment' => 'test comment' ); |
|
113
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param ); |
|
114
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
115
|
|
|
$this->object->setView( $this->view ); |
|
116
|
|
|
|
|
117
|
|
|
$this->object->init(); |
|
118
|
|
|
|
|
119
|
|
|
$this->assertEmpty( $this->view->get( 'standardStepActive' ) ); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
|
|
123
|
|
|
public function testInitOptionOK() |
|
124
|
|
|
{ |
|
125
|
|
|
$this->view->standardBasket = $this->getBasket(); |
|
126
|
|
|
$this->object->setView( $this->view ); |
|
127
|
|
|
|
|
128
|
|
|
$param = array( |
|
129
|
|
|
'cs_order' => '1', |
|
130
|
|
|
'cs_option_terms' => '1', |
|
131
|
|
|
'cs_option_terms_value' => '1', |
|
132
|
|
|
); |
|
133
|
|
|
|
|
134
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param ); |
|
135
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
136
|
|
|
|
|
137
|
|
|
$this->object->init(); |
|
138
|
|
|
$this->assertEquals( null, $this->view->get( 'standardStepActive' ) ); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
|
|
142
|
|
|
public function testInitOptionInvalid() |
|
143
|
|
|
{ |
|
144
|
|
|
$this->view->standardBasket = $this->getBasket(); |
|
145
|
|
|
$this->object->setView( $this->view ); |
|
146
|
|
|
|
|
147
|
|
|
$param = array( |
|
148
|
|
|
'cs_order' => '1', |
|
149
|
|
|
'cs_option_terms' => '1', |
|
150
|
|
|
); |
|
151
|
|
|
|
|
152
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param ); |
|
153
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
154
|
|
|
|
|
155
|
|
|
$this->object->init(); |
|
156
|
|
|
$this->assertEquals( 'summary', $this->view->get( 'standardStepActive' ) ); |
|
157
|
|
|
$this->assertArrayHasKey( 'option', $this->view->get( 'summaryErrorCodes', [] ) ); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
|
|
161
|
|
|
public function testInitSkip() |
|
162
|
|
|
{ |
|
163
|
|
|
$this->object->init(); |
|
164
|
|
|
|
|
165
|
|
|
$this->assertEmpty( $this->view->get( 'standardStepActive' ) ); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
|
|
169
|
|
|
protected function getBasket() |
|
170
|
|
|
{ |
|
171
|
|
|
$controller = \Aimeos\Controller\Frontend::create( $this->context, 'basket' ); |
|
172
|
|
|
|
|
173
|
|
|
$customerManager = \Aimeos\MShop::create( $this->context, 'customer' ); |
|
174
|
|
|
$address = $customerManager->find( '[email protected]' )->getPaymentAddress()->toArray(); |
|
175
|
|
|
|
|
176
|
|
|
$controller->addAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $address ); |
|
177
|
|
|
$controller->addAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $address ); |
|
178
|
|
|
|
|
179
|
|
|
$productManager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context ); |
|
180
|
|
|
$controller->addProduct( $productManager->find( 'CNE', ['price'] ), 2 ); |
|
181
|
|
|
|
|
182
|
|
|
$domains = ['media', 'price', 'text']; |
|
183
|
|
|
$serviceManager = \Aimeos\MShop::create( $this->context, 'service' ); |
|
184
|
|
|
$controller->addService( $serviceManager->find( 'unitpaymentcode', $domains, 'service', 'payment' ) ); |
|
185
|
|
|
$controller->addService( $serviceManager->find( 'unitdeliverycode', $domains, 'service', 'delivery' ) ); |
|
186
|
|
|
|
|
187
|
|
|
return $controller->get(); |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|