|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Aimeos\Client\Html\Checkout\Confirm; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
8
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
|
9
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
10
|
|
|
*/ |
|
11
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
private $object; |
|
14
|
|
|
private $context; |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
protected function setUp() : void |
|
18
|
|
|
{ |
|
19
|
|
|
$this->view = \TestHelper::view(); |
|
|
|
|
|
|
20
|
|
|
$this->context = \TestHelper::context(); |
|
21
|
|
|
$this->context->setEditor( '[email protected]' ); |
|
22
|
|
|
|
|
23
|
|
|
$this->object = new \Aimeos\Client\Html\Checkout\Confirm\Standard( $this->context ); |
|
24
|
|
|
$this->object->setView( $this->view ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
protected function tearDown() : void |
|
29
|
|
|
{ |
|
30
|
|
|
unset( $this->context, $this->object, $this->view ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
public function testHeader() |
|
35
|
|
|
{ |
|
36
|
|
|
$order = $this->getOrder( '2011-09-17 16:14:32' ); |
|
37
|
|
|
$this->context->session()->set( 'aimeos/orderid', $order->getId() ); |
|
38
|
|
|
|
|
39
|
|
|
$this->view->confirmOrderItem = $order; |
|
40
|
|
|
$this->view->summaryBasket = $order->getBaseItem(); |
|
41
|
|
|
|
|
42
|
|
|
$output = $this->object->header(); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertStringContainsString( '<title>Confirmation | Aimeos</title>', $output ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
public function testBody() |
|
49
|
|
|
{ |
|
50
|
|
|
$order = $this->getOrder( '2011-09-17 16:14:32' ); |
|
51
|
|
|
$this->context->session()->set( 'aimeos/orderid', $order->getId() ); |
|
52
|
|
|
|
|
53
|
|
|
$this->view->confirmOrderItem = $order; |
|
54
|
|
|
$this->view->summaryBasket = $order->getBaseItem(); |
|
55
|
|
|
|
|
56
|
|
|
$output = $this->object->body(); |
|
57
|
|
|
|
|
58
|
|
|
$this->assertStringContainsString( '<section class="aimeos checkout-confirm"', $output ); |
|
59
|
|
|
$this->assertStringContainsString( '<div class="checkout-confirm-intro">', $output ); |
|
60
|
|
|
$this->assertStringContainsString( '<div class="checkout-confirm-retry">', $output ); |
|
61
|
|
|
$this->assertStringContainsString( '<div class="checkout-confirm-basic">', $output ); |
|
62
|
|
|
$this->assertStringContainsString( '<div class="checkout-confirm-detail', $output ); |
|
63
|
|
|
$this->assertStringContainsString( '<div class="checkout-confirm-detail common-summary">', $output ); |
|
64
|
|
|
$this->assertRegExp( '#<span class="value">.*' . $order->getId() . '.*</span>#smU', $output ); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertStringContainsString( 'mr Our Unittest', $output ); |
|
67
|
|
|
$this->assertStringContainsString( 'Example company', $output ); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertStringContainsString( 'unitdeliverycode', $output ); |
|
70
|
|
|
$this->assertStringContainsString( 'paypal', $output ); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertStringContainsString( 'This is a comment', $output ); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
public function testInit() |
|
77
|
|
|
{ |
|
78
|
|
|
$orderId = $this->getOrder( '2011-09-17 16:14:32' )->getId(); |
|
79
|
|
|
$this->context->session()->set( 'aimeos/orderid', $orderId ); |
|
80
|
|
|
|
|
81
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, ['code' => 'paypalexpress', 'orderid' => $orderId] ); |
|
82
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
83
|
|
|
|
|
84
|
|
|
$request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock(); |
|
85
|
|
|
$helper = new \Aimeos\Base\View\Helper\Request\Standard( $this->view, $request, '127.0.0.1', 'test' ); |
|
86
|
|
|
$this->view->addHelper( 'request', $helper ); |
|
87
|
|
|
|
|
88
|
|
|
$this->expectException( \Aimeos\MShop\Exception::class ); |
|
89
|
|
|
$this->object->init(); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
public function testInitNoCode() |
|
94
|
|
|
{ |
|
95
|
|
|
$this->expectException( \Aimeos\Client\Html\Exception::class ); |
|
96
|
|
|
$this->object->init(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param string $date |
|
102
|
|
|
*/ |
|
103
|
|
|
protected function getOrder( $date ) |
|
104
|
|
|
{ |
|
105
|
|
|
$domains = ['order/base', 'order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service']; |
|
106
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( $this->context ); |
|
107
|
|
|
$search = $manager->filter()->add( 'order.datepayment', '==', $date ); |
|
108
|
|
|
|
|
109
|
|
|
return $manager->search( $search, $domains )->first( new \RuntimeException( 'No order found' ) ); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|