1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Admin\JQAdm\Product\Bundle; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
private $object; |
16
|
|
|
private $view; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() |
20
|
|
|
{ |
21
|
|
|
$this->view = \TestHelperJqadm::getView(); |
22
|
|
|
$this->context = \TestHelperJqadm::getContext(); |
23
|
|
|
$templatePaths = \TestHelperJqadm::getTemplatePaths(); |
24
|
|
|
|
25
|
|
|
$this->object = new \Aimeos\Admin\JQAdm\Product\Bundle\Standard( $this->context, $templatePaths ); |
26
|
|
|
$this->object->setView( $this->view ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
protected function tearDown() |
31
|
|
|
{ |
32
|
|
|
unset( $this->object ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testCreate() |
37
|
|
|
{ |
38
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
39
|
|
|
|
40
|
|
|
$this->view->item = $manager->createItem(); |
41
|
|
|
$result = $this->object->create(); |
42
|
|
|
|
43
|
|
|
$this->assertContains( 'Bundles', $result ); |
44
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
public function testCopy() |
49
|
|
|
{ |
50
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
51
|
|
|
|
52
|
|
|
$this->view->item = $manager->findItem( 'U:BUNDLE', array( 'product' ) ); |
53
|
|
|
$result = $this->object->copy(); |
54
|
|
|
|
55
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
56
|
|
|
$this->assertContains( 'Cafe Noire Cappuccino', $result ); |
57
|
|
|
$this->assertContains( 'Cafe Noire Expresso', $result ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
public function testDelete() |
62
|
|
|
{ |
63
|
|
|
$result = $this->object->delete(); |
64
|
|
|
|
65
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
66
|
|
|
$this->assertNull( $result ); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
public function testGet() |
71
|
|
|
{ |
72
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
73
|
|
|
|
74
|
|
|
$this->view->item = $manager->findItem( 'U:BUNDLE', array( 'product' ) ); |
75
|
|
|
$result = $this->object->get(); |
76
|
|
|
|
77
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
78
|
|
|
$this->assertContains( 'Cafe Noire Cappuccino', $result ); |
79
|
|
|
$this->assertContains( 'Cafe Noire Expresso', $result ); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
public function testSave() |
84
|
|
|
{ |
85
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
86
|
|
|
|
87
|
|
|
$item = $manager->findItem( 'U:BUNDLE' ); |
88
|
|
|
$item->setCode( 'jqadm-test-bundle' ); |
89
|
|
|
$item->setId( null ); |
90
|
|
|
|
91
|
|
|
$manager->saveItem( $item ); |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
$param = array( |
95
|
|
|
'bundle' => array( |
96
|
|
|
'product.lists.id' => array( '' ), |
97
|
|
|
'product.lists.refid' => array( $manager->findItem( 'CNE' )->getId() ), |
98
|
|
|
), |
99
|
|
|
); |
100
|
|
|
|
101
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param ); |
102
|
|
|
$this->view->addHelper( 'param', $helper ); |
103
|
|
|
$this->view->item = $item; |
104
|
|
|
|
105
|
|
|
$result = $this->object->save(); |
106
|
|
|
|
107
|
|
|
$item = $manager->getItem( $item->getId(), array( 'product' ) ); |
108
|
|
|
$manager->deleteItem( $item->getId() ); |
109
|
|
|
|
110
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
111
|
|
|
$this->assertNull( $result ); |
112
|
|
|
$this->assertEquals( 1, count( $item->getListItems( 'product' ) ) ); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
public function testSaveException() |
117
|
|
|
{ |
118
|
|
|
$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Bundle\Standard' ) |
119
|
|
|
->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) ) |
120
|
|
|
->setMethods( array( 'updateItems' ) ) |
121
|
|
|
->getMock(); |
122
|
|
|
|
123
|
|
|
$object->expects( $this->once() )->method( 'updateItems' ) |
124
|
|
|
->will( $this->throwException( new \Exception() ) ); |
125
|
|
|
|
126
|
|
|
$object->setView( \TestHelperJqadm::getView() ); |
127
|
|
|
|
128
|
|
|
$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' ); |
|
|
|
|
129
|
|
|
$object->save(); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
public function testSaveMShopException() |
134
|
|
|
{ |
135
|
|
|
$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Bundle\Standard' ) |
136
|
|
|
->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) ) |
137
|
|
|
->setMethods( array( 'updateItems' ) ) |
138
|
|
|
->getMock(); |
139
|
|
|
|
140
|
|
|
$object->expects( $this->once() )->method( 'updateItems' ) |
141
|
|
|
->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
142
|
|
|
|
143
|
|
|
$object->setView( \TestHelperJqadm::getView() ); |
144
|
|
|
|
145
|
|
|
$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' ); |
|
|
|
|
146
|
|
|
$object->save(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
|
150
|
|
|
public function testSearch() |
151
|
|
|
{ |
152
|
|
|
$this->assertNull( $this->object->search() ); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
public function testGetSubClient() |
157
|
|
|
{ |
158
|
|
|
$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' ); |
|
|
|
|
159
|
|
|
$this->object->getSubClient( 'invalid' ); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.