Completed
Push — master ( 201bf3...094a7b )
by Aimeos
02:16
created
lib/custom/tests/MShop/Customer/Manager/FosUserTest.php 1 patch
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -21,41 +21,41 @@  discard block
 block discarded – undo
21 21
 	{
22 22
 		$context = \TestHelper::getContext();
23 23
 		$this->editor = $context->getEditor();
24
-		$this->object = new \Aimeos\MShop\Customer\Manager\FosUser( $context );
24
+		$this->object = new \Aimeos\MShop\Customer\Manager\FosUser($context);
25 25
 
26 26
 		$this->fixture = array(
27 27
 			'label' => 'unitTest',
28 28
 			'status' => 2,
29 29
 		);
30 30
 
31
-		$this->address = new \Aimeos\MShop\Common\Item\Address\Standard( 'common.address.' );
31
+		$this->address = new \Aimeos\MShop\Common\Item\Address\Standard('common.address.');
32 32
 	}
33 33
 
34 34
 
35 35
 	protected function tearDown()
36 36
 	{
37
-		unset( $this->object, $this->fixture, $this->address );
37
+		unset($this->object, $this->fixture, $this->address);
38 38
 	}
39 39
 
40 40
 
41 41
 	public function testCleanup()
42 42
 	{
43
-		$this->object->cleanup( array( -1 ) );
43
+		$this->object->cleanup(array( -1 ));
44 44
 	}
45 45
 
46 46
 
47 47
 	public function testGetSearchAttributes()
48 48
 	{
49
-		foreach( $this->object->getSearchAttributes() as $attribute )
49
+		foreach ($this->object->getSearchAttributes() as $attribute)
50 50
 		{
51
-			$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Attribute\\Iface', $attribute );
51
+			$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Attribute\\Iface', $attribute);
52 52
 		}
53 53
 	}
54 54
 
55 55
 
56 56
 	public function testCreateItem()
57 57
 	{
58
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Customer\\Item\\Iface', $this->object->createItem() );
58
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Customer\\Item\\Iface', $this->object->createItem());
59 59
 	}
60 60
 
61 61
 
@@ -63,21 +63,21 @@  discard block
 block discarded – undo
63 63
 	{
64 64
 		$search = $this->object->createSearch();
65 65
 		$conditions = array(
66
-			$search->compare( '==', 'customer.code', 'UTC003' ),
67
-			$search->compare( '==', 'customer.editor', $this->editor )
66
+			$search->compare('==', 'customer.code', 'UTC003'),
67
+			$search->compare('==', 'customer.editor', $this->editor)
68 68
 		);
69
-		$search->setConditions( $search->combine( '&&', $conditions ) );
70
-		$items = $this->object->searchItems( $search, array( 'text' ) );
69
+		$search->setConditions($search->combine('&&', $conditions));
70
+		$items = $this->object->searchItems($search, array('text'));
71 71
 
72
-		if( ( $expected = reset( $items ) ) === false ) {
73
-			throw new \RuntimeException( 'No customer item with code "UTC003" found' );
72
+		if (($expected = reset($items)) === false) {
73
+			throw new \RuntimeException('No customer item with code "UTC003" found');
74 74
 		}
75 75
 
76
-		$actual = $this->object->getItem( $expected->getId(), array( 'text' ) );
76
+		$actual = $this->object->getItem($expected->getId(), array('text'));
77 77
 
78
-		$this->assertEquals( $expected, $actual );
79
-		$this->assertEquals( 3, count( $actual->getListItems( 'text' ) ) );
80
-		$this->assertEquals( 3, count( $actual->getRefItems( 'text' ) ) );
78
+		$this->assertEquals($expected, $actual);
79
+		$this->assertEquals(3, count($actual->getListItems('text')));
80
+		$this->assertEquals(3, count($actual->getRefItems('text')));
81 81
 	}
82 82
 
83 83
 
@@ -85,96 +85,96 @@  discard block
 block discarded – undo
85 85
 	{
86 86
 		$item = $this->object->createItem();
87 87
 
88
-		$item->setCode( 'unitTest' );
89
-		$item->setLabel( 'unitTest' );
90
-		$resultSaved = $this->object->saveItem( $item );
91
-		$itemSaved = $this->object->getItem( $item->getId() );
88
+		$item->setCode('unitTest');
89
+		$item->setLabel('unitTest');
90
+		$resultSaved = $this->object->saveItem($item);
91
+		$itemSaved = $this->object->getItem($item->getId());
92 92
 
93 93
 		$itemExp = clone $itemSaved;
94
-		$itemExp->setCode( 'unitTest2' );
95
-		$itemExp->setLabel( 'unitTest2' );
96
-		$resultUpd = $this->object->saveItem( $itemExp );
97
-		$itemUpd = $this->object->getItem( $itemExp->getId() );
98
-
99
-		$this->object->deleteItem( $item->getId() );
100
-
101
-		$this->assertTrue( $item->getId() !== null );
102
-		$this->assertEquals( $item->getId(), $itemSaved->getId() );
103
-		$this->assertEquals( $item->getSiteId(), $itemSaved->getSiteId() );
104
-		$this->assertEquals( $item->getStatus(), $itemSaved->getStatus() );
105
-		$this->assertEquals( $item->getCode(), $itemSaved->getCode() );
106
-		$this->assertEquals( $item->getLabel(), $itemSaved->getLabel() );
107
-		$this->assertEquals( $item->getPaymentAddress(), $itemSaved->getPaymentAddress() );
108
-		$this->assertEquals( $item->getBirthday(), $itemSaved->getBirthday() );
109
-		$this->assertEquals( $item->getPassword(), $itemSaved->getPassword() );
110
-		$this->assertEquals( $item->getRoles(), $itemSaved->getRoles() );
111
-		$this->assertEquals( $item->getSalt(), $itemSaved->getSalt() );
112
-
113
-		$this->assertEquals( $this->editor, $itemSaved->getEditor() );
114
-		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeCreated() );
115
-		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeModified() );
116
-
117
-		$this->assertEquals( $itemExp->getId(), $itemUpd->getId() );
118
-		$this->assertEquals( $itemExp->getSiteId(), $itemUpd->getSiteId() );
119
-		$this->assertEquals( $itemExp->getStatus(), $itemUpd->getStatus() );
120
-		$this->assertEquals( $itemExp->getCode(), $itemUpd->getCode() );
121
-		$this->assertEquals( $itemExp->getLabel(), $itemUpd->getLabel() );
122
-		$this->assertEquals( $itemExp->getPaymentAddress(), $itemUpd->getPaymentAddress() );
123
-		$this->assertEquals( $itemExp->getBirthday(), $itemUpd->getBirthday() );
124
-		$this->assertEquals( $itemExp->getPassword(), $itemUpd->getPassword() );
125
-		$this->assertEquals( $itemExp->getRoles(), $itemUpd->getRoles() );
126
-		$this->assertEquals( $itemExp->getSalt(), $itemUpd->getSalt() );
127
-
128
-		$this->assertEquals( $this->editor, $itemUpd->getEditor() );
129
-		$this->assertEquals( $itemExp->getTimeCreated(), $itemUpd->getTimeCreated() );
130
-		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemUpd->getTimeModified() );
131
-
132
-		$this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Iface', $resultSaved );
133
-		$this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Iface', $resultUpd );
134
-
135
-		$this->setExpectedException( '\\Aimeos\\MShop\\Exception' );
136
-		$this->object->getItem( $item->getId() );
94
+		$itemExp->setCode('unitTest2');
95
+		$itemExp->setLabel('unitTest2');
96
+		$resultUpd = $this->object->saveItem($itemExp);
97
+		$itemUpd = $this->object->getItem($itemExp->getId());
98
+
99
+		$this->object->deleteItem($item->getId());
100
+
101
+		$this->assertTrue($item->getId() !== null);
102
+		$this->assertEquals($item->getId(), $itemSaved->getId());
103
+		$this->assertEquals($item->getSiteId(), $itemSaved->getSiteId());
104
+		$this->assertEquals($item->getStatus(), $itemSaved->getStatus());
105
+		$this->assertEquals($item->getCode(), $itemSaved->getCode());
106
+		$this->assertEquals($item->getLabel(), $itemSaved->getLabel());
107
+		$this->assertEquals($item->getPaymentAddress(), $itemSaved->getPaymentAddress());
108
+		$this->assertEquals($item->getBirthday(), $itemSaved->getBirthday());
109
+		$this->assertEquals($item->getPassword(), $itemSaved->getPassword());
110
+		$this->assertEquals($item->getRoles(), $itemSaved->getRoles());
111
+		$this->assertEquals($item->getSalt(), $itemSaved->getSalt());
112
+
113
+		$this->assertEquals($this->editor, $itemSaved->getEditor());
114
+		$this->assertRegExp('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeCreated());
115
+		$this->assertRegExp('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeModified());
116
+
117
+		$this->assertEquals($itemExp->getId(), $itemUpd->getId());
118
+		$this->assertEquals($itemExp->getSiteId(), $itemUpd->getSiteId());
119
+		$this->assertEquals($itemExp->getStatus(), $itemUpd->getStatus());
120
+		$this->assertEquals($itemExp->getCode(), $itemUpd->getCode());
121
+		$this->assertEquals($itemExp->getLabel(), $itemUpd->getLabel());
122
+		$this->assertEquals($itemExp->getPaymentAddress(), $itemUpd->getPaymentAddress());
123
+		$this->assertEquals($itemExp->getBirthday(), $itemUpd->getBirthday());
124
+		$this->assertEquals($itemExp->getPassword(), $itemUpd->getPassword());
125
+		$this->assertEquals($itemExp->getRoles(), $itemUpd->getRoles());
126
+		$this->assertEquals($itemExp->getSalt(), $itemUpd->getSalt());
127
+
128
+		$this->assertEquals($this->editor, $itemUpd->getEditor());
129
+		$this->assertEquals($itemExp->getTimeCreated(), $itemUpd->getTimeCreated());
130
+		$this->assertRegExp('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemUpd->getTimeModified());
131
+
132
+		$this->assertInstanceOf('\Aimeos\MShop\Common\Item\Iface', $resultSaved);
133
+		$this->assertInstanceOf('\Aimeos\MShop\Common\Item\Iface', $resultUpd);
134
+
135
+		$this->setExpectedException('\\Aimeos\\MShop\\Exception');
136
+		$this->object->getItem($item->getId());
137 137
 	}
138 138
 
139 139
 
140 140
 	public function testGetSaveAddressItems()
141 141
 	{
142
-		$item = $this->object->findItem( 'UTC001', ['customer/address'] );
142
+		$item = $this->object->findItem('UTC001', ['customer/address']);
143 143
 
144
-		$item->setId( null )->setCode( 'xyz' );
145
-		$item->getPaymentAddress()->setEmail( '[email protected]' );
146
-		$item->addAddressItem( new \Aimeos\MShop\Common\Item\Address\Standard( 'customer.address.' ) );
147
-		$this->object->saveItem( $item );
144
+		$item->setId(null)->setCode('xyz');
145
+		$item->getPaymentAddress()->setEmail('[email protected]');
146
+		$item->addAddressItem(new \Aimeos\MShop\Common\Item\Address\Standard('customer.address.'));
147
+		$this->object->saveItem($item);
148 148
 
149
-		$item2 = $this->object->findItem( 'xyz', ['customer/address'] );
149
+		$item2 = $this->object->findItem('xyz', ['customer/address']);
150 150
 
151
-		$this->object->deleteItem( $item->getId() );
151
+		$this->object->deleteItem($item->getId());
152 152
 
153
-		$this->assertEquals( 2, count( $item->getAddressItems() ) );
154
-		$this->assertEquals( 2, count( $item2->getAddressItems() ) );
153
+		$this->assertEquals(2, count($item->getAddressItems()));
154
+		$this->assertEquals(2, count($item2->getAddressItems()));
155 155
 	}
156 156
 
157 157
 
158 158
 	public function testGetSavePropertyItems()
159 159
 	{
160
-		$item = $this->object->findItem( 'UTC001', ['customer/property'] );
160
+		$item = $this->object->findItem('UTC001', ['customer/property']);
161 161
 
162
-		$item->setId( null )->setCode( 'xyz' );
163
-		$item->getPaymentAddress()->setEmail( '[email protected]' );
164
-		$this->object->saveItem( $item );
162
+		$item->setId(null)->setCode('xyz');
163
+		$item->getPaymentAddress()->setEmail('[email protected]');
164
+		$this->object->saveItem($item);
165 165
 
166
-		$item2 = $this->object->findItem( 'xyz', ['customer/property'] );
166
+		$item2 = $this->object->findItem('xyz', ['customer/property']);
167 167
 
168
-		$this->object->deleteItem( $item->getId() );
168
+		$this->object->deleteItem($item->getId());
169 169
 
170
-		$this->assertEquals( 1, count( $item->getPropertyItems() ) );
171
-		$this->assertEquals( 1, count( $item2->getPropertyItems() ) );
170
+		$this->assertEquals(1, count($item->getPropertyItems()));
171
+		$this->assertEquals(1, count($item2->getPropertyItems()));
172 172
 	}
173 173
 
174 174
 
175 175
 	public function testCreateSearch()
176 176
 	{
177
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $this->object->createSearch() );
177
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $this->object->createSearch());
178 178
 	}
179 179
 
180 180
 
@@ -184,69 +184,69 @@  discard block
 block discarded – undo
184 184
 		$search = $this->object->createSearch();
185 185
 
186 186
 		$expr = [];
187
-		$expr[] = $search->compare( '!=', 'customer.id', null );
188
-		$expr[] = $search->compare( '==', 'customer.label', 'UTC002' );
189
-		$expr[] = $search->compare( '==', 'customer.code', 'UTC002' );
190
-
191
-		$expr[] = $search->compare( '>=', 'customer.salutation', '' );
192
-		$expr[] = $search->compare( '>=', 'customer.company', '' );
193
-		$expr[] = $search->compare( '>=', 'customer.vatid', '' );
194
-		$expr[] = $search->compare( '>=', 'customer.title', '' );
195
-		$expr[] = $search->compare( '>=', 'customer.firstname', '' );
196
-		$expr[] = $search->compare( '>=', 'customer.lastname', '' );
197
-		$expr[] = $search->compare( '>=', 'customer.address1', '' );
198
-		$expr[] = $search->compare( '>=', 'customer.address2', '' );
199
-		$expr[] = $search->compare( '>=', 'customer.address3', '' );
200
-		$expr[] = $search->compare( '>=', 'customer.postal', '' );
201
-		$expr[] = $search->compare( '>=', 'customer.city', '' );
202
-		$expr[] = $search->compare( '>=', 'customer.state', '' );
203
-		$expr[] = $search->compare( '!=', 'customer.languageid', null );
204
-		$expr[] = $search->compare( '>=', 'customer.countryid', '' );
205
-		$expr[] = $search->compare( '>=', 'customer.telephone', '' );
206
-		$expr[] = $search->compare( '>=', 'customer.email', '' );
207
-		$expr[] = $search->compare( '>=', 'customer.telefax', '' );
208
-		$expr[] = $search->compare( '>=', 'customer.website', '' );
209
-		$expr[] = $search->compare( '>=', 'customer.longitude', '10.0' );
210
-		$expr[] = $search->compare( '>=', 'customer.latitude', '50.0' );
211
-
212
-		$expr[] = $search->compare( '==', 'customer.birthday', '1970-01-01' );
213
-		$expr[] = $search->compare( '>=', 'customer.password', '' );
214
-		$expr[] = $search->compare( '==', 'customer.status', 0 );
215
-		$expr[] = $search->compare( '!=', 'customer.mtime', '1970-01-01 00:00:00' );
216
-		$expr[] = $search->compare( '!=', 'customer.ctime', '1970-01-01 00:00:00' );
217
-		$expr[] = $search->compare( '==', 'customer.editor', $this->editor );
218
-
219
-		$expr[] = $search->compare( '!=', 'customer.address.id', null );
220
-		$expr[] = $search->compare( '!=', 'customer.address.parentid', null );
221
-		$expr[] = $search->compare( '==', 'customer.address.company', 'ABC GmbH' );
222
-		$expr[] = $search->compare( '==', 'customer.address.vatid', 'DE999999999' );
223
-		$expr[] = $search->compare( '==', 'customer.address.salutation', 'mr' );
224
-		$expr[] = $search->compare( '==', 'customer.address.title', 'Dr.' );
225
-		$expr[] = $search->compare( '==', 'customer.address.firstname', 'Good' );
226
-		$expr[] = $search->compare( '==', 'customer.address.lastname', 'Unittest' );
227
-		$expr[] = $search->compare( '==', 'customer.address.address1', 'Pickhuben' );
228
-		$expr[] = $search->compare( '==', 'customer.address.address2', '2-4' );
229
-		$expr[] = $search->compare( '==', 'customer.address.address3', '' );
230
-		$expr[] = $search->compare( '==', 'customer.address.postal', '11099' );
231
-		$expr[] = $search->compare( '==', 'customer.address.city', 'Berlin' );
232
-		$expr[] = $search->compare( '==', 'customer.address.state', 'Berlin' );
233
-		$expr[] = $search->compare( '==', 'customer.address.languageid', 'de' );
234
-		$expr[] = $search->compare( '==', 'customer.address.countryid', 'DE' );
235
-		$expr[] = $search->compare( '==', 'customer.address.telephone', '055544332221' );
236
-		$expr[] = $search->compare( '==', 'customer.address.email', '[email protected]' );
237
-		$expr[] = $search->compare( '==', 'customer.address.telefax', '055544333212' );
238
-		$expr[] = $search->compare( '==', 'customer.address.website', 'unittest.aimeos.org' );
239
-		$expr[] = $search->compare( '>=', 'customer.address.longitude', '10.0' );
240
-		$expr[] = $search->compare( '>=', 'customer.address.latitude', '50.0' );
241
-		$expr[] = $search->compare( '==', 'customer.address.flag', 0 );
242
-		$expr[] = $search->compare( '==', 'customer.address.position', 1 );
243
-		$expr[] = $search->compare( '!=', 'customer.address.mtime', '1970-01-01 00:00:00' );
244
-		$expr[] = $search->compare( '!=', 'customer.address.ctime', '1970-01-01 00:00:00' );
245
-		$expr[] = $search->compare( '==', 'customer.address.editor', $this->editor );
246
-
247
-		$search->setConditions( $search->combine( '&&', $expr ) );
248
-		$result = $this->object->searchItems( $search, [], $total );
249
-		$this->assertEquals( 1, count( $result ) );
187
+		$expr[] = $search->compare('!=', 'customer.id', null);
188
+		$expr[] = $search->compare('==', 'customer.label', 'UTC002');
189
+		$expr[] = $search->compare('==', 'customer.code', 'UTC002');
190
+
191
+		$expr[] = $search->compare('>=', 'customer.salutation', '');
192
+		$expr[] = $search->compare('>=', 'customer.company', '');
193
+		$expr[] = $search->compare('>=', 'customer.vatid', '');
194
+		$expr[] = $search->compare('>=', 'customer.title', '');
195
+		$expr[] = $search->compare('>=', 'customer.firstname', '');
196
+		$expr[] = $search->compare('>=', 'customer.lastname', '');
197
+		$expr[] = $search->compare('>=', 'customer.address1', '');
198
+		$expr[] = $search->compare('>=', 'customer.address2', '');
199
+		$expr[] = $search->compare('>=', 'customer.address3', '');
200
+		$expr[] = $search->compare('>=', 'customer.postal', '');
201
+		$expr[] = $search->compare('>=', 'customer.city', '');
202
+		$expr[] = $search->compare('>=', 'customer.state', '');
203
+		$expr[] = $search->compare('!=', 'customer.languageid', null);
204
+		$expr[] = $search->compare('>=', 'customer.countryid', '');
205
+		$expr[] = $search->compare('>=', 'customer.telephone', '');
206
+		$expr[] = $search->compare('>=', 'customer.email', '');
207
+		$expr[] = $search->compare('>=', 'customer.telefax', '');
208
+		$expr[] = $search->compare('>=', 'customer.website', '');
209
+		$expr[] = $search->compare('>=', 'customer.longitude', '10.0');
210
+		$expr[] = $search->compare('>=', 'customer.latitude', '50.0');
211
+
212
+		$expr[] = $search->compare('==', 'customer.birthday', '1970-01-01');
213
+		$expr[] = $search->compare('>=', 'customer.password', '');
214
+		$expr[] = $search->compare('==', 'customer.status', 0);
215
+		$expr[] = $search->compare('!=', 'customer.mtime', '1970-01-01 00:00:00');
216
+		$expr[] = $search->compare('!=', 'customer.ctime', '1970-01-01 00:00:00');
217
+		$expr[] = $search->compare('==', 'customer.editor', $this->editor);
218
+
219
+		$expr[] = $search->compare('!=', 'customer.address.id', null);
220
+		$expr[] = $search->compare('!=', 'customer.address.parentid', null);
221
+		$expr[] = $search->compare('==', 'customer.address.company', 'ABC GmbH');
222
+		$expr[] = $search->compare('==', 'customer.address.vatid', 'DE999999999');
223
+		$expr[] = $search->compare('==', 'customer.address.salutation', 'mr');
224
+		$expr[] = $search->compare('==', 'customer.address.title', 'Dr.');
225
+		$expr[] = $search->compare('==', 'customer.address.firstname', 'Good');
226
+		$expr[] = $search->compare('==', 'customer.address.lastname', 'Unittest');
227
+		$expr[] = $search->compare('==', 'customer.address.address1', 'Pickhuben');
228
+		$expr[] = $search->compare('==', 'customer.address.address2', '2-4');
229
+		$expr[] = $search->compare('==', 'customer.address.address3', '');
230
+		$expr[] = $search->compare('==', 'customer.address.postal', '11099');
231
+		$expr[] = $search->compare('==', 'customer.address.city', 'Berlin');
232
+		$expr[] = $search->compare('==', 'customer.address.state', 'Berlin');
233
+		$expr[] = $search->compare('==', 'customer.address.languageid', 'de');
234
+		$expr[] = $search->compare('==', 'customer.address.countryid', 'DE');
235
+		$expr[] = $search->compare('==', 'customer.address.telephone', '055544332221');
236
+		$expr[] = $search->compare('==', 'customer.address.email', '[email protected]');
237
+		$expr[] = $search->compare('==', 'customer.address.telefax', '055544333212');
238
+		$expr[] = $search->compare('==', 'customer.address.website', 'unittest.aimeos.org');
239
+		$expr[] = $search->compare('>=', 'customer.address.longitude', '10.0');
240
+		$expr[] = $search->compare('>=', 'customer.address.latitude', '50.0');
241
+		$expr[] = $search->compare('==', 'customer.address.flag', 0);
242
+		$expr[] = $search->compare('==', 'customer.address.position', 1);
243
+		$expr[] = $search->compare('!=', 'customer.address.mtime', '1970-01-01 00:00:00');
244
+		$expr[] = $search->compare('!=', 'customer.address.ctime', '1970-01-01 00:00:00');
245
+		$expr[] = $search->compare('==', 'customer.address.editor', $this->editor);
246
+
247
+		$search->setConditions($search->combine('&&', $expr));
248
+		$result = $this->object->searchItems($search, [], $total);
249
+		$this->assertEquals(1, count($result));
250 250
 	}
251 251
 
252 252
 
@@ -255,60 +255,60 @@  discard block
 block discarded – undo
255 255
 		$total = 0;
256 256
 
257 257
 		$search = $this->object->createSearch();
258
-		$search->setConditions( $search->compare( '==', 'customer.address.editor', $this->editor ) );
259
-		$search->setSlice( 0, 2 );
258
+		$search->setConditions($search->compare('==', 'customer.address.editor', $this->editor));
259
+		$search->setSlice(0, 2);
260 260
 
261
-		$results = $this->object->searchItems( $search, [], $total );
262
-		$this->assertEquals( 2, count( $results ) );
263
-		$this->assertEquals( 3, $total );
261
+		$results = $this->object->searchItems($search, [], $total);
262
+		$this->assertEquals(2, count($results));
263
+		$this->assertEquals(3, $total);
264 264
 
265
-		foreach($results as $itemId => $item) {
266
-			$this->assertEquals( $itemId, $item->getId() );
265
+		foreach ($results as $itemId => $item) {
266
+			$this->assertEquals($itemId, $item->getId());
267 267
 		}
268 268
 	}
269 269
 
270 270
 
271 271
 	public function testSearchItemsCriteria()
272 272
 	{
273
-		$search = $this->object->createSearch( true );
273
+		$search = $this->object->createSearch(true);
274 274
 		$conditions = array(
275
-			$search->compare( '==', 'customer.address.editor', $this->editor ),
275
+			$search->compare('==', 'customer.address.editor', $this->editor),
276 276
 			$search->getConditions()
277 277
 		);
278
-		$search->setConditions( $search->combine( '&&', $conditions ) );
279
-		$this->assertEquals( 2, count( $this->object->searchItems( $search, [], $total ) ) );
278
+		$search->setConditions($search->combine('&&', $conditions));
279
+		$this->assertEquals(2, count($this->object->searchItems($search, [], $total)));
280 280
 	}
281 281
 
282 282
 
283 283
 	public function testSearchItemsRef()
284 284
 	{
285 285
 		$search = $this->object->createSearch();
286
-		$search->setConditions( $search->compare( '==', 'customer.code', 'UTC001' ) );
286
+		$search->setConditions($search->compare('==', 'customer.code', 'UTC001'));
287 287
 
288
-		$results = $this->object->searchItems( $search, ['customer/address', 'text'] );
288
+		$results = $this->object->searchItems($search, ['customer/address', 'text']);
289 289
 
290
-		if( ( $item = reset( $results ) ) === false ) {
291
-			throw new \Exception( 'No customer item for "UTC001" available' );
290
+		if (($item = reset($results)) === false) {
291
+			throw new \Exception('No customer item for "UTC001" available');
292 292
 		}
293 293
 
294
-		$this->assertEquals( 1, count( $item->getRefItems( 'text' ) ) );
295
-		$this->assertEquals( 1, count( $item->getAddressItems() ) );
294
+		$this->assertEquals(1, count($item->getRefItems('text')));
295
+		$this->assertEquals(1, count($item->getAddressItems()));
296 296
 	}
297 297
 
298 298
 
299 299
 	public function testGetSubManager()
300 300
 	{
301
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager( 'address' ) );
302
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager( 'address', 'Standard' ) );
301
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager('address'));
302
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager('address', 'Standard'));
303 303
 
304
-		$this->setExpectedException( '\\Aimeos\\MShop\\Exception' );
305
-		$this->object->getSubManager( 'unknown' );
304
+		$this->setExpectedException('\\Aimeos\\MShop\\Exception');
305
+		$this->object->getSubManager('unknown');
306 306
 	}
307 307
 
308 308
 
309 309
 	public function testGetSubManagerInvalidName()
310 310
 	{
311
-		$this->setExpectedException( '\\Aimeos\\MShop\\Exception' );
312
-		$this->object->getSubManager( 'address', 'unknown' );
311
+		$this->setExpectedException('\\Aimeos\\MShop\\Exception');
312
+		$this->object->getSubManager('address', 'unknown');
313 313
 	}
314 314
 }
Please login to merge, or discard this patch.
lib/custom/src/MShop/Customer/Manager/FosUser.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 * @param array $siteids List of IDs for sites whose entries should be deleted
245 245
 	 */
246
-	public function cleanup( array $siteids )
246
+	public function cleanup(array $siteids)
247 247
 	{
248 248
 		$path = 'mshop/customer/manager/submanagers';
249
-		foreach( $this->getContext()->getConfig()->get( $path, array( 'address', 'lists' ) ) as $domain ) {
250
-			$this->getObject()->getSubManager( $domain )->cleanup( $siteids );
249
+		foreach ($this->getContext()->getConfig()->get($path, array('address', 'lists')) as $domain) {
250
+			$this->getObject()->getSubManager($domain)->cleanup($siteids);
251 251
 		}
252 252
 	}
253 253
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @param array $ids List of IDs
259 259
 	 */
260
-	public function deleteItems( array $ids )
260
+	public function deleteItems(array $ids)
261 261
 	{
262 262
 		$path = 'mshop/customer/manager/fosuser/delete';
263
-		$this->deleteItemsBase( $ids, $path, false );
263
+		$this->deleteItemsBase($ids, $path, false);
264 264
 	}
265 265
 
266 266
 
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	 * @param boolean $withsub Return also attributes of sub-managers if true
271 271
 	 * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
272 272
 	 */
273
-	public function getSearchAttributes( $withsub = true )
273
+	public function getSearchAttributes($withsub = true)
274 274
 	{
275 275
 		$path = 'mshop/customer/manager/submanagers';
276 276
 
277
-		return $this->getSearchAttributesBase( $this->searchConfig, $path, array( 'address', 'lists' ), $withsub );
277
+		return $this->getSearchAttributesBase($this->searchConfig, $path, array('address', 'lists'), $withsub);
278 278
 	}
279 279
 
280 280
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 */
286 286
 	public function createItem()
287 287
 	{
288
-		return $this->createItemBase( ['customer.siteid' => $this->getContext()->getLocale()->getSiteId()] );
288
+		return $this->createItemBase(['customer.siteid' => $this->getContext()->getLocale()->getSiteId()]);
289 289
 	}
290 290
 
291 291
 
@@ -296,32 +296,32 @@  discard block
 block discarded – undo
296 296
 	 * @param boolean $fetch True if the new ID should be returned in the item
297 297
 	 * @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID
298 298
 	 */
299
-	public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
299
+	public function saveItem(\Aimeos\MShop\Common\Item\Iface $item, $fetch = true)
300 300
 	{
301 301
 		$iface = '\\Aimeos\\MShop\\Customer\\Item\\FosUser';
302
-		if( !( $item instanceof $iface ) ) {
303
-			throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
302
+		if (!($item instanceof $iface)) {
303
+			throw new \Aimeos\MShop\Customer\Exception(sprintf('Object is not of required type "%1$s"', $iface));
304 304
 		}
305 305
 
306
-		if( !$item->isModified() )
306
+		if (!$item->isModified())
307 307
 		{
308
-			$item = $this->savePropertyItems( $item, 'customer' );
309
-			$item = $this->saveAddressItems( $item, 'customer' );
310
-			return $this->saveRefItems( $item, 'customer' );
308
+			$item = $this->savePropertyItems($item, 'customer');
309
+			$item = $this->saveAddressItems($item, 'customer');
310
+			return $this->saveRefItems($item, 'customer');
311 311
 		}
312 312
 
313 313
 		$context = $this->getContext();
314 314
 		$dbm = $context->getDatabaseManager();
315 315
 		$dbname = $this->getResourceName();
316
-		$conn = $dbm->acquire( $dbname );
316
+		$conn = $dbm->acquire($dbname);
317 317
 
318 318
 		try
319 319
 		{
320 320
 			$id = $item->getId();
321
-			$date = date( 'Y-m-d H:i:s' );
321
+			$date = date('Y-m-d H:i:s');
322 322
 			$billingAddress = $item->getPaymentAddress();
323 323
 
324
-			if( $id === null )
324
+			if ($id === null)
325 325
 			{
326 326
 				/** mshop/customer/manager/fosuser/insert
327 327
 				 * Inserts a new customer record into the database table
@@ -385,51 +385,51 @@  discard block
 block discarded – undo
385 385
 				$path = 'mshop/customer/manager/fosuser/update';
386 386
 			}
387 387
 
388
-			$stmt = $this->getCachedStatement( $conn, $path );
389
-
390
-			$stmt->bind( 1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
391
-			$stmt->bind( 2, $item->getCode() ); // canonical username
392
-			$stmt->bind( 3, $item->getCode() ); // username
393
-			$stmt->bind( 4, $billingAddress->getCompany() );
394
-			$stmt->bind( 5, $billingAddress->getVatID() );
395
-			$stmt->bind( 6, $billingAddress->getSalutation() );
396
-			$stmt->bind( 7, $billingAddress->getTitle() );
397
-			$stmt->bind( 8, $billingAddress->getFirstname() );
398
-			$stmt->bind( 9, $billingAddress->getLastname() );
399
-			$stmt->bind( 10, $billingAddress->getAddress1() );
400
-			$stmt->bind( 11, $billingAddress->getAddress2() );
401
-			$stmt->bind( 12, $billingAddress->getAddress3() );
402
-			$stmt->bind( 13, $billingAddress->getPostal() );
403
-			$stmt->bind( 14, $billingAddress->getCity() );
404
-			$stmt->bind( 15, $billingAddress->getState() );
405
-			$stmt->bind( 16, $billingAddress->getCountryId() );
406
-			$stmt->bind( 17, $billingAddress->getLanguageId() );
407
-			$stmt->bind( 18, $billingAddress->getTelephone() );
408
-			$stmt->bind( 19, $billingAddress->getEmail() );
409
-			$stmt->bind( 20, $billingAddress->getEmail() );
410
-			$stmt->bind( 21, $billingAddress->getTelefax() );
411
-			$stmt->bind( 22, $billingAddress->getWebsite() );
412
-			$stmt->bind( 23, $billingAddress->getLongitude() );
413
-			$stmt->bind( 24, $billingAddress->getLatitude() );
414
-			$stmt->bind( 25, $item->getBirthday() );
415
-			$stmt->bind( 26, ( $item->getStatus() > 0 ? true : false ), \Aimeos\MW\DB\Statement\Base::PARAM_BOOL );
416
-			$stmt->bind( 27, $item->getDateVerified() );
417
-			$stmt->bind( 28, $item->getPassword() );
418
-			$stmt->bind( 29, $date ); // Modification time
419
-			$stmt->bind( 30, $context->getEditor() );
420
-			$stmt->bind( 31, serialize( $item->getRoles() ) );
421
-			$stmt->bind( 32, $item->getSalt() );
422
-
423
-			if( $id !== null ) {
424
-				$stmt->bind( 33, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
425
-				$item->setId( $id );
388
+			$stmt = $this->getCachedStatement($conn, $path);
389
+
390
+			$stmt->bind(1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
391
+			$stmt->bind(2, $item->getCode()); // canonical username
392
+			$stmt->bind(3, $item->getCode()); // username
393
+			$stmt->bind(4, $billingAddress->getCompany());
394
+			$stmt->bind(5, $billingAddress->getVatID());
395
+			$stmt->bind(6, $billingAddress->getSalutation());
396
+			$stmt->bind(7, $billingAddress->getTitle());
397
+			$stmt->bind(8, $billingAddress->getFirstname());
398
+			$stmt->bind(9, $billingAddress->getLastname());
399
+			$stmt->bind(10, $billingAddress->getAddress1());
400
+			$stmt->bind(11, $billingAddress->getAddress2());
401
+			$stmt->bind(12, $billingAddress->getAddress3());
402
+			$stmt->bind(13, $billingAddress->getPostal());
403
+			$stmt->bind(14, $billingAddress->getCity());
404
+			$stmt->bind(15, $billingAddress->getState());
405
+			$stmt->bind(16, $billingAddress->getCountryId());
406
+			$stmt->bind(17, $billingAddress->getLanguageId());
407
+			$stmt->bind(18, $billingAddress->getTelephone());
408
+			$stmt->bind(19, $billingAddress->getEmail());
409
+			$stmt->bind(20, $billingAddress->getEmail());
410
+			$stmt->bind(21, $billingAddress->getTelefax());
411
+			$stmt->bind(22, $billingAddress->getWebsite());
412
+			$stmt->bind(23, $billingAddress->getLongitude());
413
+			$stmt->bind(24, $billingAddress->getLatitude());
414
+			$stmt->bind(25, $item->getBirthday());
415
+			$stmt->bind(26, ($item->getStatus() > 0 ? true : false), \Aimeos\MW\DB\Statement\Base::PARAM_BOOL);
416
+			$stmt->bind(27, $item->getDateVerified());
417
+			$stmt->bind(28, $item->getPassword());
418
+			$stmt->bind(29, $date); // Modification time
419
+			$stmt->bind(30, $context->getEditor());
420
+			$stmt->bind(31, serialize($item->getRoles()));
421
+			$stmt->bind(32, $item->getSalt());
422
+
423
+			if ($id !== null) {
424
+				$stmt->bind(33, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
425
+				$item->setId($id);
426 426
 			} else {
427
-				$stmt->bind( 33, $date ); // Creation time
427
+				$stmt->bind(33, $date); // Creation time
428 428
 			}
429 429
 
430 430
 			$stmt->execute()->finish();
431 431
 
432
-			if( $id === null && $fetch === true )
432
+			if ($id === null && $fetch === true)
433 433
 			{
434 434
 				/** mshop/customer/manager/fosuser/newid
435 435
 				 * Retrieves the ID generated by the database when inserting a new record
@@ -462,22 +462,22 @@  discard block
 block discarded – undo
462 462
 				 * @see mshop/customer/manager/fosuser/count
463 463
 				 */
464 464
 				$path = 'mshop/customer/manager/fosuser/newid';
465
-				$item->setId( $this->newId( $conn, $path ) );
465
+				$item->setId($this->newId($conn, $path));
466 466
 			}
467 467
 
468
-			$dbm->release( $conn, $dbname );
468
+			$dbm->release($conn, $dbname);
469 469
 		}
470
-		catch( \Exception $e )
470
+		catch (\Exception $e)
471 471
 		{
472
-			$dbm->release( $conn, $dbname );
472
+			$dbm->release($conn, $dbname);
473 473
 			throw $e;
474 474
 		}
475 475
 
476
-		$this->addGroups( $item );
476
+		$this->addGroups($item);
477 477
 
478
-		$item = $this->savePropertyItems( $item, 'customer' );
479
-		$item = $this->saveAddressItems( $item, 'customer' );
480
-		return $this->saveRefItems( $item, 'customer' );
478
+		$item = $this->savePropertyItems($item, 'customer');
479
+		$item = $this->saveAddressItems($item, 'customer');
480
+		return $this->saveRefItems($item, 'customer');
481 481
 	}
482 482
 
483 483
 
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 	 * @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface
490 490
 	 * @throws \Aimeos\MShop\Customer\Exception If creating items failed
491 491
 	 */
492
-	public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null )
492
+	public function searchItems(\Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null)
493 493
 	{
494 494
 		$dbm = $this->getContext()->getDatabaseManager();
495 495
 		$dbname = $this->getResourceName();
496
-		$conn = $dbm->acquire( $dbname );
496
+		$conn = $dbm->acquire($dbname);
497 497
 		$map = [];
498 498
 
499 499
 		try
@@ -501,32 +501,32 @@  discard block
 block discarded – undo
501 501
 			$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
502 502
 			$cfgPathSearch = 'mshop/customer/manager/fosuser/search';
503 503
 			$cfgPathCount = 'mshop/customer/manager/fosuser/count';
504
-			$required = array( 'customer' );
504
+			$required = array('customer');
505 505
 
506
-			$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
507
-			while( ( $row = $results->fetch() ) !== false ) {
508
-				$map[ $row['customer.id'] ] = $row;
506
+			$results = $this->searchItemsBase($conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level);
507
+			while (($row = $results->fetch()) !== false) {
508
+				$map[$row['customer.id']] = $row;
509 509
 			}
510 510
 
511
-			$dbm->release( $conn, $dbname );
511
+			$dbm->release($conn, $dbname);
512 512
 		}
513
-		catch( \Exception $e )
513
+		catch (\Exception $e)
514 514
 		{
515
-			$dbm->release( $conn, $dbname  );
515
+			$dbm->release($conn, $dbname);
516 516
 			throw $e;
517 517
 		}
518 518
 
519 519
 		$addrItems = [];
520
-		if( in_array( 'customer/address', $ref, true ) ) {
521
-			$addrItems = $this->getAddressItems( array_keys( $map ), 'customer' );
520
+		if (in_array('customer/address', $ref, true)) {
521
+			$addrItems = $this->getAddressItems(array_keys($map), 'customer');
522 522
 		}
523 523
 
524 524
 		$propItems = [];
525
-		if( in_array( 'customer/property', $ref, true ) ) {
526
-			$propItems = $this->getPropertyItems( array_keys( $map ), 'customer' );
525
+		if (in_array('customer/property', $ref, true)) {
526
+			$propItems = $this->getPropertyItems(array_keys($map), 'customer');
527 527
 		}
528 528
 
529
-		return $this->buildItems( $map, $ref, 'customer', $addrItems, $propItems );
529
+		return $this->buildItems($map, $ref, 'customer', $addrItems, $propItems);
530 530
 	}
531 531
 
532 532
 
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
 	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
538 538
 	 * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.
539 539
 	 */
540
-	public function getSubManager( $manager, $name = null )
540
+	public function getSubManager($manager, $name = null)
541 541
 	{
542
-		return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'FosUser' : $name ) );
542
+		return $this->getSubManagerBase('customer', $manager, ($name === null ? 'FosUser' : $name));
543 543
 	}
544 544
 
545 545
 
@@ -553,15 +553,15 @@  discard block
 block discarded – undo
553 553
 	 * @param array $propItems List of property items of the customer item
554 554
 	 * @return \Aimeos\MShop\Customer\Item\Iface New customer item
555 555
 	 */
556
-	protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [],
557
-		array $addresses = [], array $propItems = [] )
556
+	protected function createItemBase(array $values = [], array $listItems = [], array $refItems = [],
557
+		array $addresses = [], array $propItems = [])
558 558
 	{
559
-		if( !isset( $this->addressManager ) ) {
560
-			$this->addressManager = $this->getObject()->getSubManager( 'address' );
559
+		if (!isset($this->addressManager)) {
560
+			$this->addressManager = $this->getObject()->getSubManager('address');
561 561
 		}
562 562
 
563
-		if( isset( $values['roles'] ) ) {
564
-			$values['roles'] = unserialize( $values['roles'] );
563
+		if (isset($values['roles'])) {
564
+			$values['roles'] = unserialize($values['roles']);
565 565
 		}
566 566
 
567 567
 		$helper = $this->getPasswordHelper();
Please login to merge, or discard this patch.