|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Client\Html\Checkout\Update; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $object; |
|
15
|
|
|
private $context; |
|
16
|
|
|
private $view; |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
protected function setUp() : void |
|
20
|
|
|
{ |
|
21
|
|
|
$this->view = \TestHelperHtml::view(); |
|
22
|
|
|
$this->context = \TestHelperHtml::context(); |
|
23
|
|
|
|
|
24
|
|
|
$this->object = new \Aimeos\Client\Html\Checkout\Update\Standard( $this->context ); |
|
25
|
|
|
$this->object->setView( $this->view ); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
protected function tearDown() : void |
|
30
|
|
|
{ |
|
31
|
|
|
unset( $this->context, $this->object, $this->view ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function testHeader() |
|
36
|
|
|
{ |
|
37
|
|
|
$output = $this->object->header(); |
|
38
|
|
|
$this->assertNotNull( $output ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
public function testBody() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->assertEquals( '', $this->object->body() ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
public function testInit() |
|
49
|
|
|
{ |
|
50
|
|
|
$params = array( |
|
51
|
|
|
'code' => 'paypalexpress', |
|
52
|
|
|
'orderid' => $this->getOrder( '2011-09-17 16:14:32' )->getId(), |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
56
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
57
|
|
|
|
|
58
|
|
|
$request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock(); |
|
59
|
|
|
$helper = new \Aimeos\MW\View\Helper\Request\Standard( $this->view, $request, '127.0.0.1', 'test' ); |
|
60
|
|
|
$this->view->addHelper( 'request', $helper ); |
|
61
|
|
|
|
|
62
|
|
|
$this->object->init(); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertEquals( 400, $this->view->response()->getStatusCode() ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
public function testInitException() |
|
69
|
|
|
{ |
|
70
|
|
|
$mock = $this->getMockBuilder( '\\Aimeos\\Controller\\Frontend\\Service\Standard' ) |
|
71
|
|
|
->setConstructorArgs( [$this->context] ) |
|
72
|
|
|
->setMethods( ['updatePush'] ) |
|
73
|
|
|
->getMock(); |
|
74
|
|
|
|
|
75
|
|
|
$mock->expects( $this->once() )->method( 'updatePush' ) |
|
76
|
|
|
->will( $this->throwException( new \RuntimeException() ) ); |
|
77
|
|
|
|
|
78
|
|
|
\Aimeos\Controller\Frontend\Service\Factory::injectController( '\\Aimeos\\Controller\\Frontend\\Service\\Standard', $mock ); |
|
79
|
|
|
$this->object->init(); |
|
80
|
|
|
\Aimeos\Controller\Frontend\Service\Factory::injectController( '\\Aimeos\\Controller\\Frontend\\Service\\Standard', null ); |
|
81
|
|
|
|
|
82
|
|
|
$this->assertEquals( 500, $this->view->response()->getStatusCode() ); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param string $date |
|
88
|
|
|
*/ |
|
89
|
|
|
protected function getOrder( $date ) |
|
90
|
|
|
{ |
|
91
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( $this->context ); |
|
92
|
|
|
|
|
93
|
|
|
$search = $manager->filter(); |
|
94
|
|
|
$search->setConditions( $search->compare( '==', 'order.datepayment', $date ) ); |
|
95
|
|
|
|
|
96
|
|
|
if( ( $item = $manager->search( $search )->first() ) === null ) { |
|
97
|
|
|
throw new \RuntimeException( 'No order found' ); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
return $item; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|