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\Text; |
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\Text\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( 'Texts', $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( 'ABCD', array( 'text' ) ); |
53
|
|
|
$result = $this->object->copy(); |
54
|
|
|
|
55
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
56
|
|
|
$this->assertContains( 'value="Unterproduct 1"', $result ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
public function testDelete() |
61
|
|
|
{ |
62
|
|
|
$result = $this->object->delete(); |
63
|
|
|
|
64
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
65
|
|
|
$this->assertNull( $result ); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
public function testGet() |
70
|
|
|
{ |
71
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
72
|
|
|
|
73
|
|
|
$this->view->item = $manager->findItem( 'ABCD', array( 'text' ) ); |
74
|
|
|
$result = $this->object->get(); |
75
|
|
|
|
76
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
77
|
|
|
$this->assertContains( 'value="Unterproduct 1"', $result ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
public function testSave() |
82
|
|
|
{ |
83
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
84
|
|
|
|
85
|
|
|
$item = $manager->findItem( 'CNC' ); |
86
|
|
|
$item->setCode( 'jqadm-test-save' ); |
87
|
|
|
$item->setId( null ); |
88
|
|
|
|
89
|
|
|
$manager->saveItem( $item ); |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
$param = array( |
93
|
|
|
'text' => array( |
94
|
|
|
'langid' => array( 'de' ), |
95
|
|
|
'name' => array( 'listid' => '', 'content' => 'test name' ), |
96
|
|
|
'short' => array( 'listid' => '', 'content' => 'short desc' ), |
97
|
|
|
'long' => array( 'listid' => '', 'content' => 'long desc' ), |
98
|
|
|
'url' => array( 'listid' => '', 'content' => 'url segment' ), |
99
|
|
|
'meta-keyword' => array( 'listid' => '', 'content' => 'meta keywords' ), |
100
|
|
|
'meta-description' => array( 'listid' => '', 'content' => 'meta desc' ), |
101
|
|
|
), |
102
|
|
|
); |
103
|
|
|
|
104
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param ); |
105
|
|
|
$this->view->addHelper( 'param', $helper ); |
106
|
|
|
$this->view->item = $item; |
107
|
|
|
|
108
|
|
|
$result = $this->object->save(); |
109
|
|
|
|
110
|
|
|
$item = $manager->getItem( $item->getId(), array( 'text' ) ); |
111
|
|
|
$manager->deleteItem( $item->getId() ); |
112
|
|
|
|
113
|
|
|
$this->assertNull( $this->view->get( 'errors' ) ); |
114
|
|
|
$this->assertNull( $result ); |
115
|
|
|
$this->assertEquals( 6, count( $item->getListItems() ) ); |
116
|
|
|
|
117
|
|
|
foreach( $item->getListItems( 'text' ) as $listItem ) |
118
|
|
|
{ |
119
|
|
|
$this->assertEquals( 'text', $listItem->getDomain() ); |
120
|
|
|
$this->assertEquals( 'default', $listItem->getType() ); |
121
|
|
|
|
122
|
|
|
$refItem = $listItem->getRefItem(); |
123
|
|
|
$this->assertEquals( 'de', $refItem->getLanguageId() ); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
public function testSaveException() |
129
|
|
|
{ |
130
|
|
|
$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Text\Standard' ) |
131
|
|
|
->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) ) |
132
|
|
|
->setMethods( array( 'updateItems' ) ) |
133
|
|
|
->getMock(); |
134
|
|
|
|
135
|
|
|
$object->expects( $this->once() )->method( 'updateItems' ) |
136
|
|
|
->will( $this->throwException( new \Exception() ) ); |
137
|
|
|
|
138
|
|
|
$object->setView( \TestHelperJqadm::getView() ); |
139
|
|
|
|
140
|
|
|
$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' ); |
|
|
|
|
141
|
|
|
$object->save(); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
public function testSaveMShopException() |
146
|
|
|
{ |
147
|
|
|
$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Text\Standard' ) |
148
|
|
|
->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) ) |
149
|
|
|
->setMethods( array( 'updateItems' ) ) |
150
|
|
|
->getMock(); |
151
|
|
|
|
152
|
|
|
$object->expects( $this->once() )->method( 'updateItems' ) |
153
|
|
|
->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
154
|
|
|
|
155
|
|
|
$object->setView( \TestHelperJqadm::getView() ); |
156
|
|
|
|
157
|
|
|
$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' ); |
|
|
|
|
158
|
|
|
$object->save(); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
|
162
|
|
|
public function testSearch() |
163
|
|
|
{ |
164
|
|
|
$this->assertNull( $this->object->search() ); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
|
168
|
|
|
public function testGetSubClient() |
169
|
|
|
{ |
170
|
|
|
$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' ); |
|
|
|
|
171
|
|
|
$this->object->getSubClient( 'invalid' ); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|
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.