@@ -18,206 +18,206 @@ |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - if( !interface_exists( 'eZ\Publish\API\Repository\UserService' ) ) { |
|
22 | - $this->markTestSkipped( 'Install ezsystems/ezpublish-api first' ); |
|
21 | + if (!interface_exists('eZ\Publish\API\Repository\UserService')) { |
|
22 | + $this->markTestSkipped('Install ezsystems/ezpublish-api first'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $this->context = \TestHelper::getContext(); |
26 | 26 | |
27 | - $this->object = new \Aimeos\MShop\Customer\Manager\Ezpublish( $this->context ); |
|
28 | - $this->address = new \Aimeos\MShop\Common\Item\Address\Standard( 'common.address.' ); |
|
27 | + $this->object = new \Aimeos\MShop\Customer\Manager\Ezpublish($this->context); |
|
28 | + $this->address = new \Aimeos\MShop\Common\Item\Address\Standard('common.address.'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
32 | 32 | protected function tearDown() |
33 | 33 | { |
34 | - unset( $this->object, $this->context, $this->address ); |
|
34 | + unset($this->object, $this->context, $this->address); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testCleanup() |
39 | 39 | { |
40 | - $this->object->cleanup( array( -1 ) ); |
|
40 | + $this->object->cleanup(array( -1 )); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testCreateItem() |
45 | 45 | { |
46 | - $this->assertInstanceOf( 'Aimeos\MShop\Customer\Item\Iface', $this->object->createItem() ); |
|
46 | + $this->assertInstanceOf('Aimeos\MShop\Customer\Item\Iface', $this->object->createItem()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testDeleteItems() |
51 | 51 | { |
52 | - $mock = $this->getMockBuilder( 'eZ\Publish\API\Repository\UserService' )->getMock(); |
|
53 | - $user = $this->getMockBuilder( 'eZ\Publish\API\Repository\Values\User\User' )->getMock(); |
|
52 | + $mock = $this->getMockBuilder('eZ\Publish\API\Repository\UserService')->getMock(); |
|
53 | + $user = $this->getMockBuilder('eZ\Publish\API\Repository\Values\User\User')->getMock(); |
|
54 | 54 | |
55 | - $mock->expects( $this->once() )->method( 'loadUser' )->will( $this->returnValue( $user ) ); |
|
56 | - $mock->expects( $this->once() )->method( 'deleteUser' ); |
|
55 | + $mock->expects($this->once())->method('loadUser')->will($this->returnValue($user)); |
|
56 | + $mock->expects($this->once())->method('deleteUser'); |
|
57 | 57 | |
58 | - $this->context->setEzUserService( $mock ); |
|
59 | - $this->object->deleteItems( array( -1 ) ); |
|
58 | + $this->context->setEzUserService($mock); |
|
59 | + $this->object->deleteItems(array( -1 )); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | public function testGetSearchAttributes() |
64 | 64 | { |
65 | 65 | $attributes = $this->object->getSearchAttributes(); |
66 | - $this->assertGreaterThan( 0, count( $attributes ) ); |
|
66 | + $this->assertGreaterThan(0, count($attributes)); |
|
67 | 67 | |
68 | - foreach( $attributes as $attribute ) { |
|
69 | - $this->assertInstanceOf( '\Aimeos\MW\Criteria\Attribute\Iface', $attribute ); |
|
68 | + foreach ($attributes as $attribute) { |
|
69 | + $this->assertInstanceOf('\Aimeos\MW\Criteria\Attribute\Iface', $attribute); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testGetSubManager() |
75 | 75 | { |
76 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Manager\Iface', $this->object->getSubManager( 'address' ) ); |
|
77 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Manager\Iface', $this->object->getSubManager( 'address', 'Standard' ) ); |
|
76 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Manager\Iface', $this->object->getSubManager('address')); |
|
77 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Manager\Iface', $this->object->getSubManager('address', 'Standard')); |
|
78 | 78 | |
79 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
80 | - $this->object->getSubManager( 'unknown' ); |
|
79 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
80 | + $this->object->getSubManager('unknown'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | 84 | public function testGetSubManagerInvalidName() |
85 | 85 | { |
86 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
87 | - $this->object->getSubManager( 'address', 'unknown' ); |
|
86 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
87 | + $this->object->getSubManager('address', 'unknown'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | public function testSaveItemInsert() |
92 | 92 | { |
93 | - $service = $this->getMockBuilder( 'eZ\Publish\API\Repository\UserService' )->getMock(); |
|
94 | - $struct = $this->getMockBuilder( 'eZ\Publish\API\Repository\Values\User\UserCreateStruct' )->getMock(); |
|
95 | - $user = $this->getMockBuilder( '\eZ\Publish\API\Repository\Values\User\User' ) |
|
96 | - ->setMethods( array( 'getUserId', 'getVersionInfo', 'getFieldValue', 'getFields', 'getFieldsByLanguage' ) ) |
|
93 | + $service = $this->getMockBuilder('eZ\Publish\API\Repository\UserService')->getMock(); |
|
94 | + $struct = $this->getMockBuilder('eZ\Publish\API\Repository\Values\User\UserCreateStruct')->getMock(); |
|
95 | + $user = $this->getMockBuilder('\eZ\Publish\API\Repository\Values\User\User') |
|
96 | + ->setMethods(array('getUserId', 'getVersionInfo', 'getFieldValue', 'getFields', 'getFieldsByLanguage')) |
|
97 | 97 | ->getMock(); |
98 | 98 | |
99 | - $dbm = $this->getMockBuilder( 'Aimeos\MW\DB\Manager\Iface' )->getMock(); |
|
100 | - $conn = $this->getMockBuilder( 'Aimeos\MW\DB\Connection\Iface' )->getMock(); |
|
101 | - $stmt = $this->getMockBuilder( 'Aimeos\MW\DB\Statement\Iface' )->getMock(); |
|
102 | - $result = $this->getMockBuilder( 'Aimeos\MW\DB\Result\Iface' )->getMock(); |
|
99 | + $dbm = $this->getMockBuilder('Aimeos\MW\DB\Manager\Iface')->getMock(); |
|
100 | + $conn = $this->getMockBuilder('Aimeos\MW\DB\Connection\Iface')->getMock(); |
|
101 | + $stmt = $this->getMockBuilder('Aimeos\MW\DB\Statement\Iface')->getMock(); |
|
102 | + $result = $this->getMockBuilder('Aimeos\MW\DB\Result\Iface')->getMock(); |
|
103 | 103 | |
104 | - $service->expects( $this->once() )->method( 'newUserCreateStruct' )->will( $this->returnValue( $struct ) ); |
|
105 | - $service->expects( $this->once() )->method( 'createUser' )->will( $this->returnValue( $user ) ); |
|
106 | - $user->expects( $this->once() )->method( 'getUserId' )->will( $this->returnValue( 1 ) ); |
|
107 | - $dbm->expects( $this->once() )->method( 'acquire' )->will( $this->returnValue( $conn ) ); |
|
108 | - $conn->expects( $this->once() )->method( 'create' )->will( $this->returnValue( $stmt ) ); |
|
109 | - $stmt->expects( $this->once() )->method( 'execute' )->will( $this->returnValue( $result ) ); |
|
104 | + $service->expects($this->once())->method('newUserCreateStruct')->will($this->returnValue($struct)); |
|
105 | + $service->expects($this->once())->method('createUser')->will($this->returnValue($user)); |
|
106 | + $user->expects($this->once())->method('getUserId')->will($this->returnValue(1)); |
|
107 | + $dbm->expects($this->once())->method('acquire')->will($this->returnValue($conn)); |
|
108 | + $conn->expects($this->once())->method('create')->will($this->returnValue($stmt)); |
|
109 | + $stmt->expects($this->once())->method('execute')->will($this->returnValue($result)); |
|
110 | 110 | |
111 | 111 | |
112 | - $this->context->setDatabaseManager( $dbm ); |
|
113 | - $this->context->setEzUserService( $service ); |
|
112 | + $this->context->setDatabaseManager($dbm); |
|
113 | + $this->context->setEzUserService($service); |
|
114 | 114 | |
115 | - $this->object->saveItem( new \Aimeos\MShop\Customer\Item\Standard( $this->address ) ); |
|
115 | + $this->object->saveItem(new \Aimeos\MShop\Customer\Item\Standard($this->address)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | 119 | public function testSaveItemUpdate() |
120 | 120 | { |
121 | - $service = $this->getMockBuilder( 'eZ\Publish\API\Repository\UserService' )->getMock(); |
|
122 | - $user = $this->getMockBuilder( 'eZ\Publish\API\Repository\Values\User\User' )->getMock(); |
|
123 | - $struct = $this->getMockBuilder( 'eZ\Publish\API\Repository\Values\User\UserUpdateStruct' )->getMock(); |
|
124 | - $dbm = $this->getMockBuilder( 'Aimeos\MW\DB\Manager\Iface' )->getMock(); |
|
125 | - $conn = $this->getMockBuilder( 'Aimeos\MW\DB\Connection\Iface' )->getMock(); |
|
126 | - $stmt = $this->getMockBuilder( 'Aimeos\MW\DB\Statement\Iface' )->getMock(); |
|
127 | - $result = $this->getMockBuilder( 'Aimeos\MW\DB\Result\Iface' )->getMock(); |
|
128 | - |
|
129 | - $service->expects( $this->once() )->method( 'updateUser' ); |
|
130 | - $service->expects( $this->once() )->method( 'loadUser' )->will( $this->returnValue( $user ) ); |
|
131 | - $service->expects( $this->once() )->method( 'newUserUpdateStruct' )->will( $this->returnValue( $struct ) ); |
|
132 | - $dbm->expects( $this->once() )->method( 'acquire' )->will( $this->returnValue( $conn ) ); |
|
133 | - $conn->expects( $this->once() )->method( 'create' )->will( $this->returnValue( $stmt ) ); |
|
134 | - $stmt->expects( $this->once() )->method( 'execute' )->will( $this->returnValue( $result ) ); |
|
135 | - $result->expects( $this->once() )->method( 'finish' ); |
|
136 | - $dbm->expects( $this->once() )->method( 'release' ); |
|
137 | - |
|
138 | - |
|
139 | - $item = new \Aimeos\MShop\Customer\Item\Standard( $this->address, array( 'customer.id' => 1 ) ); |
|
140 | - $item->setStatus( 1 ); |
|
141 | - |
|
142 | - $this->context->setDatabaseManager( $dbm ); |
|
143 | - $this->context->setEzUserService( $service ); |
|
144 | - $this->object->saveItem( $item ); |
|
121 | + $service = $this->getMockBuilder('eZ\Publish\API\Repository\UserService')->getMock(); |
|
122 | + $user = $this->getMockBuilder('eZ\Publish\API\Repository\Values\User\User')->getMock(); |
|
123 | + $struct = $this->getMockBuilder('eZ\Publish\API\Repository\Values\User\UserUpdateStruct')->getMock(); |
|
124 | + $dbm = $this->getMockBuilder('Aimeos\MW\DB\Manager\Iface')->getMock(); |
|
125 | + $conn = $this->getMockBuilder('Aimeos\MW\DB\Connection\Iface')->getMock(); |
|
126 | + $stmt = $this->getMockBuilder('Aimeos\MW\DB\Statement\Iface')->getMock(); |
|
127 | + $result = $this->getMockBuilder('Aimeos\MW\DB\Result\Iface')->getMock(); |
|
128 | + |
|
129 | + $service->expects($this->once())->method('updateUser'); |
|
130 | + $service->expects($this->once())->method('loadUser')->will($this->returnValue($user)); |
|
131 | + $service->expects($this->once())->method('newUserUpdateStruct')->will($this->returnValue($struct)); |
|
132 | + $dbm->expects($this->once())->method('acquire')->will($this->returnValue($conn)); |
|
133 | + $conn->expects($this->once())->method('create')->will($this->returnValue($stmt)); |
|
134 | + $stmt->expects($this->once())->method('execute')->will($this->returnValue($result)); |
|
135 | + $result->expects($this->once())->method('finish'); |
|
136 | + $dbm->expects($this->once())->method('release'); |
|
137 | + |
|
138 | + |
|
139 | + $item = new \Aimeos\MShop\Customer\Item\Standard($this->address, array('customer.id' => 1)); |
|
140 | + $item->setStatus(1); |
|
141 | + |
|
142 | + $this->context->setDatabaseManager($dbm); |
|
143 | + $this->context->setEzUserService($service); |
|
144 | + $this->object->saveItem($item); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | 148 | public function testSaveItemInvalidItem() |
149 | 149 | { |
150 | - $this->setExpectedException( '\Aimeos\MW\Common\Exception' ); |
|
151 | - $this->object->saveItem( new \Aimeos\MShop\Common\Item\Lists\Standard( 'common.lists.' ) ); |
|
150 | + $this->setExpectedException('\Aimeos\MW\Common\Exception'); |
|
151 | + $this->object->saveItem(new \Aimeos\MShop\Common\Item\Lists\Standard('common.lists.')); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | 155 | public function testSaveItemNotModified() |
156 | 156 | { |
157 | - $item = new \Aimeos\MShop\Customer\Item\Standard( $this->address, array( 'customer.id' => 1 ) ); |
|
158 | - $this->object->saveItem( $item ); |
|
157 | + $item = new \Aimeos\MShop\Customer\Item\Standard($this->address, array('customer.id' => 1)); |
|
158 | + $this->object->saveItem($item); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | 162 | public function testSaveItemInvalidContext() |
163 | 163 | { |
164 | 164 | $context = new \Aimeos\MShop\Context\Item\Standard(); |
165 | - $context->setConfig( $this->context->getConfig() ); |
|
165 | + $context->setConfig($this->context->getConfig()); |
|
166 | 166 | |
167 | - $object = new \Aimeos\MShop\Customer\Manager\Ezpublish( $context ); |
|
167 | + $object = new \Aimeos\MShop\Customer\Manager\Ezpublish($context); |
|
168 | 168 | |
169 | - $this->setExpectedException( '\Aimeos\MShop\Customer\Exception' ); |
|
170 | - $object->saveItem( new \Aimeos\MShop\Customer\Item\Standard( $this->address ) ); |
|
169 | + $this->setExpectedException('\Aimeos\MShop\Customer\Exception'); |
|
170 | + $object->saveItem(new \Aimeos\MShop\Customer\Item\Standard($this->address)); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
174 | 174 | public function testSearchItems() |
175 | 175 | { |
176 | - $mock = $this->getMockBuilder( '\Aimeos\MShop\Customer\Manager\Ezpublish' ) |
|
177 | - ->setConstructorArgs( array( $this->context ) ) |
|
178 | - ->setMethods( array( 'searchItemsBase' ) ) |
|
176 | + $mock = $this->getMockBuilder('\Aimeos\MShop\Customer\Manager\Ezpublish') |
|
177 | + ->setConstructorArgs(array($this->context)) |
|
178 | + ->setMethods(array('searchItemsBase')) |
|
179 | 179 | ->getMock(); |
180 | 180 | |
181 | - $result1 = $this->getMockBuilder( '\Aimeos\MW\DB\Result\Iface' )->getMock(); |
|
181 | + $result1 = $this->getMockBuilder('\Aimeos\MW\DB\Result\Iface')->getMock(); |
|
182 | 182 | |
183 | - $mock->expects( $this->once() )->method( 'searchItemsBase' )->will( $this->returnValue( $result1 ) ); |
|
184 | - $result1->expects( $this->exactly( 2 ) )->method( 'fetch' ) |
|
185 | - ->will( $this->onConsecutiveCalls( array( 'customer.id' => -1 ), false ) ); |
|
183 | + $mock->expects($this->once())->method('searchItemsBase')->will($this->returnValue($result1)); |
|
184 | + $result1->expects($this->exactly(2))->method('fetch') |
|
185 | + ->will($this->onConsecutiveCalls(array('customer.id' => -1), false)); |
|
186 | 186 | |
187 | 187 | |
188 | - $dbm = $this->getMockBuilder( 'Aimeos\MW\DB\Manager\Iface' )->getMock(); |
|
189 | - $conn = $this->getMockBuilder( 'Aimeos\MW\DB\Connection\Iface' )->getMock(); |
|
190 | - $stmt = $this->getMockBuilder( 'Aimeos\MW\DB\Statement\Iface' )->getMock(); |
|
191 | - $result2 = $this->getMockBuilder( '\Aimeos\MW\DB\Result\Iface' )->getMock(); |
|
188 | + $dbm = $this->getMockBuilder('Aimeos\MW\DB\Manager\Iface')->getMock(); |
|
189 | + $conn = $this->getMockBuilder('Aimeos\MW\DB\Connection\Iface')->getMock(); |
|
190 | + $stmt = $this->getMockBuilder('Aimeos\MW\DB\Statement\Iface')->getMock(); |
|
191 | + $result2 = $this->getMockBuilder('\Aimeos\MW\DB\Result\Iface')->getMock(); |
|
192 | 192 | |
193 | - $dbm->expects( $this->any() )->method( 'acquire' )->will( $this->returnValue( $conn ) ); |
|
194 | - $conn->expects( $this->once() )->method( 'create' )->will( $this->returnValue( $stmt ) ); |
|
195 | - $stmt->expects( $this->once() )->method( 'execute' )->will( $this->returnValue( $result2 ) ); |
|
196 | - $result2->expects( $this->exactly( 2 ) )->method( 'fetch' ) |
|
197 | - ->will( $this->onConsecutiveCalls( array( 'contentobject_id' => -1, 'role_id' => -2 ), false ) ); |
|
193 | + $dbm->expects($this->any())->method('acquire')->will($this->returnValue($conn)); |
|
194 | + $conn->expects($this->once())->method('create')->will($this->returnValue($stmt)); |
|
195 | + $stmt->expects($this->once())->method('execute')->will($this->returnValue($result2)); |
|
196 | + $result2->expects($this->exactly(2))->method('fetch') |
|
197 | + ->will($this->onConsecutiveCalls(array('contentobject_id' => -1, 'role_id' => -2), false)); |
|
198 | 198 | |
199 | - $dbm->expects( $this->any() )->method( 'release' ); |
|
199 | + $dbm->expects($this->any())->method('release'); |
|
200 | 200 | |
201 | 201 | |
202 | - $this->context->setDatabaseManager( $dbm ); |
|
203 | - $list = $mock->searchItems( $mock->createSearch() ); |
|
202 | + $this->context->setDatabaseManager($dbm); |
|
203 | + $list = $mock->searchItems($mock->createSearch()); |
|
204 | 204 | |
205 | - $this->assertEquals( 1, count( $list ) ); |
|
206 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $list[-1] ); |
|
205 | + $this->assertEquals(1, count($list)); |
|
206 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $list[-1]); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
210 | 210 | public function testSearchItemsException() |
211 | 211 | { |
212 | - $object = $this->getMockBuilder( '\Aimeos\MShop\Customer\Manager\Ezpublish' ) |
|
213 | - ->setConstructorArgs( array( $this->context ) ) |
|
214 | - ->setMethods( array( 'searchItemsBase' ) ) |
|
212 | + $object = $this->getMockBuilder('\Aimeos\MShop\Customer\Manager\Ezpublish') |
|
213 | + ->setConstructorArgs(array($this->context)) |
|
214 | + ->setMethods(array('searchItemsBase')) |
|
215 | 215 | ->getMock(); |
216 | 216 | |
217 | - $object->expects( $this->once() )->method( 'searchItemsBase' ) |
|
218 | - ->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
217 | + $object->expects($this->once())->method('searchItemsBase') |
|
218 | + ->will($this->throwException(new \Aimeos\MShop\Exception())); |
|
219 | 219 | |
220 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
221 | - $object->searchItems( $object->createSearch() ); |
|
220 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
221 | + $object->searchItems($object->createSearch()); |
|
222 | 222 | } |
223 | 223 | } |