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\Service\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\Service\Standard' ) |
24
|
|
|
->disableOriginalConstructor() |
25
|
|
|
->getMock(); |
26
|
|
|
|
27
|
|
|
$this->object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Service\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 testGetServices() |
40
|
|
|
{ |
41
|
|
|
$basket = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->createItem(); |
42
|
|
|
|
43
|
|
|
$this->stub->expects( $this->once() )->method( 'getServices' ) |
44
|
|
|
->will( $this->returnValue( [] ) ); |
45
|
|
|
|
46
|
|
|
$this->assertEquals( [], $this->object->getServices( 'payment', $basket ) ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
public function testGetServiceAttributes() |
51
|
|
|
{ |
52
|
|
|
$basket = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->createItem(); |
53
|
|
|
|
54
|
|
|
$this->stub->expects( $this->once() )->method( 'getServiceAttributes' ) |
55
|
|
|
->will( $this->returnValue( [] ) ); |
56
|
|
|
|
57
|
|
|
$this->assertEquals( [], $this->object->getServiceAttributes( 'payment', -1, $basket ) ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
public function testGetServicePrice() |
62
|
|
|
{ |
63
|
|
|
$priceItem = \Aimeos\MShop\Factory::createManager( $this->context, 'price' )->createItem(); |
64
|
|
|
$basket = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->createItem(); |
65
|
|
|
|
66
|
|
|
$this->stub->expects( $this->once() )->method( 'getServicePrice' ) |
67
|
|
|
->will( $this->returnValue( $priceItem ) ); |
68
|
|
|
|
69
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Price\Item\Iface', $this->object->getServicePrice( 'payment', -1, $basket ) ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
public function testCheckServiceAttributes() |
74
|
|
|
{ |
75
|
|
|
$this->stub->expects( $this->once() )->method( 'checkServiceAttributes' ) |
76
|
|
|
->will( $this->returnValue( [] ) ); |
77
|
|
|
|
78
|
|
|
$this->assertEquals( [], $this->object->checkServiceAttributes( 'payment', -1, [] ) ); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
public function testGetContext() |
83
|
|
|
{ |
84
|
|
|
$result = $this->access( 'getContext' )->invokeArgs( $this->object, [] ); |
85
|
|
|
|
86
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $result ); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
protected function access( $name ) |
91
|
|
|
{ |
92
|
|
|
$class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Service\Decorator\Base' ); |
93
|
|
|
$method = $class->getMethod( $name ); |
94
|
|
|
$method->setAccessible( true ); |
95
|
|
|
|
96
|
|
|
return $method; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|