1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Order\Decorator; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class BaseTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
private $object; |
16
|
|
|
private $stub; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() |
20
|
|
|
{ |
21
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
22
|
|
|
|
23
|
|
|
$this->stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Order\Standard' ) |
24
|
|
|
->disableOriginalConstructor() |
25
|
|
|
->getMock(); |
26
|
|
|
|
27
|
|
|
$this->object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Order\Decorator\Base' ) |
28
|
|
|
->setConstructorArgs( [$this->stub, $this->context] ) |
29
|
|
|
->getMockForAbstractClass(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
protected function tearDown() |
34
|
|
|
{ |
35
|
|
|
unset( $this->context, $this->object, $this->stub ); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function testStore() |
40
|
|
|
{ |
41
|
|
|
$orderItem = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
42
|
|
|
$basket = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->createItem(); |
43
|
|
|
|
44
|
|
|
$this->stub->expects( $this->once() )->method( 'store' ) |
45
|
|
|
->will( $this->returnValue( $orderItem ) ); |
46
|
|
|
|
47
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->store( $basket ) ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
public function testBlock() |
52
|
|
|
{ |
53
|
|
|
$orderItem = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
54
|
|
|
|
55
|
|
|
$this->stub->expects( $this->once() )->method( 'block' ); |
56
|
|
|
|
57
|
|
|
$this->object->block( $orderItem ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
public function testUnblock() |
62
|
|
|
{ |
63
|
|
|
$orderItem = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
64
|
|
|
|
65
|
|
|
$this->stub->expects( $this->once() )->method( 'unblock' ); |
66
|
|
|
|
67
|
|
|
$this->object->unblock( $orderItem ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
public function testUpdate() |
72
|
|
|
{ |
73
|
|
|
$orderItem = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
74
|
|
|
|
75
|
|
|
$this->stub->expects( $this->once() )->method( 'update' ); |
76
|
|
|
|
77
|
|
|
$this->object->update( $orderItem ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
public function testGetController() |
82
|
|
|
{ |
83
|
|
|
$result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
84
|
|
|
|
85
|
|
|
$this->assertSame( $this->stub, $result ); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
public function testGetContext() |
90
|
|
|
{ |
91
|
|
|
$result = $this->access( 'getContext' )->invokeArgs( $this->object, [] ); |
92
|
|
|
|
93
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $result ); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
protected function access( $name ) |
98
|
|
|
{ |
99
|
|
|
$class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Order\Decorator\Base' ); |
100
|
|
|
$method = $class->getMethod( $name ); |
101
|
|
|
$method->setAccessible( true ); |
102
|
|
|
|
103
|
|
|
return $method; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|