Completed
Push — master ( f709ea...d8837c )
by Aimeos
02:08
created
lib/custom/src/MShop/Customer/Manager/FosUser.php 1 patch
Spacing   +80 added lines, -80 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,29 +296,29 @@  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
 			return $item;
308 308
 		}
309 309
 
310 310
 		$context = $this->getContext();
311 311
 		$dbm = $context->getDatabaseManager();
312 312
 		$dbname = $this->getResourceName();
313
-		$conn = $dbm->acquire( $dbname );
313
+		$conn = $dbm->acquire($dbname);
314 314
 
315 315
 		try
316 316
 		{
317 317
 			$id = $item->getId();
318
-			$date = date( 'Y-m-d H:i:s' );
318
+			$date = date('Y-m-d H:i:s');
319 319
 			$billingAddress = $item->getPaymentAddress();
320 320
 
321
-			if( $id === null )
321
+			if ($id === null)
322 322
 			{
323 323
 				/** mshop/customer/manager/fosuser/insert
324 324
 				 * Inserts a new customer record into the database table
@@ -382,51 +382,51 @@  discard block
 block discarded – undo
382 382
 				$path = 'mshop/customer/manager/fosuser/update';
383 383
 			}
384 384
 
385
-			$stmt = $this->getCachedStatement( $conn, $path );
386
-
387
-			$stmt->bind( 1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
388
-			$stmt->bind( 2, $item->getCode() ); // canonical username
389
-			$stmt->bind( 3, $item->getCode() ); // username
390
-			$stmt->bind( 4, $billingAddress->getCompany() );
391
-			$stmt->bind( 5, $billingAddress->getVatID() );
392
-			$stmt->bind( 6, $billingAddress->getSalutation() );
393
-			$stmt->bind( 7, $billingAddress->getTitle() );
394
-			$stmt->bind( 8, $billingAddress->getFirstname() );
395
-			$stmt->bind( 9, $billingAddress->getLastname() );
396
-			$stmt->bind( 10, $billingAddress->getAddress1() );
397
-			$stmt->bind( 11, $billingAddress->getAddress2() );
398
-			$stmt->bind( 12, $billingAddress->getAddress3() );
399
-			$stmt->bind( 13, $billingAddress->getPostal() );
400
-			$stmt->bind( 14, $billingAddress->getCity() );
401
-			$stmt->bind( 15, $billingAddress->getState() );
402
-			$stmt->bind( 16, $billingAddress->getCountryId() );
403
-			$stmt->bind( 17, $billingAddress->getLanguageId() );
404
-			$stmt->bind( 18, $billingAddress->getTelephone() );
405
-			$stmt->bind( 19, $billingAddress->getEmail() );
406
-			$stmt->bind( 20, $billingAddress->getEmail() );
407
-			$stmt->bind( 21, $billingAddress->getTelefax() );
408
-			$stmt->bind( 22, $billingAddress->getWebsite() );
409
-			$stmt->bind( 23, $billingAddress->getLongitude() );
410
-			$stmt->bind( 24, $billingAddress->getLatitude() );
411
-			$stmt->bind( 25, $item->getBirthday() );
412
-			$stmt->bind( 26, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
413
-			$stmt->bind( 27, $item->getDateVerified() );
414
-			$stmt->bind( 28, $item->getPassword() );
415
-			$stmt->bind( 29, $date ); // Modification time
416
-			$stmt->bind( 30, $context->getEditor() );
417
-			$stmt->bind( 31, serialize( $item->getRoles() ) );
418
-			$stmt->bind( 32, $item->getSalt() );
419
-
420
-			if( $id !== null ) {
421
-				$stmt->bind( 33, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
422
-				$item->setId( $id );
385
+			$stmt = $this->getCachedStatement($conn, $path);
386
+
387
+			$stmt->bind(1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
388
+			$stmt->bind(2, $item->getCode()); // canonical username
389
+			$stmt->bind(3, $item->getCode()); // username
390
+			$stmt->bind(4, $billingAddress->getCompany());
391
+			$stmt->bind(5, $billingAddress->getVatID());
392
+			$stmt->bind(6, $billingAddress->getSalutation());
393
+			$stmt->bind(7, $billingAddress->getTitle());
394
+			$stmt->bind(8, $billingAddress->getFirstname());
395
+			$stmt->bind(9, $billingAddress->getLastname());
396
+			$stmt->bind(10, $billingAddress->getAddress1());
397
+			$stmt->bind(11, $billingAddress->getAddress2());
398
+			$stmt->bind(12, $billingAddress->getAddress3());
399
+			$stmt->bind(13, $billingAddress->getPostal());
400
+			$stmt->bind(14, $billingAddress->getCity());
401
+			$stmt->bind(15, $billingAddress->getState());
402
+			$stmt->bind(16, $billingAddress->getCountryId());
403
+			$stmt->bind(17, $billingAddress->getLanguageId());
404
+			$stmt->bind(18, $billingAddress->getTelephone());
405
+			$stmt->bind(19, $billingAddress->getEmail());
406
+			$stmt->bind(20, $billingAddress->getEmail());
407
+			$stmt->bind(21, $billingAddress->getTelefax());
408
+			$stmt->bind(22, $billingAddress->getWebsite());
409
+			$stmt->bind(23, $billingAddress->getLongitude());
410
+			$stmt->bind(24, $billingAddress->getLatitude());
411
+			$stmt->bind(25, $item->getBirthday());
412
+			$stmt->bind(26, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
413
+			$stmt->bind(27, $item->getDateVerified());
414
+			$stmt->bind(28, $item->getPassword());
415
+			$stmt->bind(29, $date); // Modification time
416
+			$stmt->bind(30, $context->getEditor());
417
+			$stmt->bind(31, serialize($item->getRoles()));
418
+			$stmt->bind(32, $item->getSalt());
419
+
420
+			if ($id !== null) {
421
+				$stmt->bind(33, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
422
+				$item->setId($id);
423 423
 			} else {
424
-				$stmt->bind( 33, $date ); // Creation time
424
+				$stmt->bind(33, $date); // Creation time
425 425
 			}
426 426
 
427 427
 			$stmt->execute()->finish();
428 428
 
429
-			if( $id === null && $fetch === true )
429
+			if ($id === null && $fetch === true)
430 430
 			{
431 431
 				/** mshop/customer/manager/fosuser/newid
432 432
 				 * Retrieves the ID generated by the database when inserting a new record
@@ -459,18 +459,18 @@  discard block
 block discarded – undo
459 459
 				 * @see mshop/customer/manager/fosuser/count
460 460
 				 */
461 461
 				$path = 'mshop/customer/manager/fosuser/newid';
462
-				$item->setId( $this->newId( $conn, $path ) );
462
+				$item->setId($this->newId($conn, $path));
463 463
 			}
464 464
 
465
-			$dbm->release( $conn, $dbname );
465
+			$dbm->release($conn, $dbname);
466 466
 		}
467
-		catch( \Exception $e )
467
+		catch (\Exception $e)
468 468
 		{
469
-			$dbm->release( $conn, $dbname );
469
+			$dbm->release($conn, $dbname);
470 470
 			throw $e;
471 471
 		}
472 472
 
473
-		$this->addGroups( $item );
473
+		$this->addGroups($item);
474 474
 
475 475
 		return $item;
476 476
 	}
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
 	 * @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface
485 485
 	 * @throws \Aimeos\MShop\Customer\Exception If creating items failed
486 486
 	 */
487
-	public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null )
487
+	public function searchItems(\Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null)
488 488
 	{
489 489
 		$dbm = $this->getContext()->getDatabaseManager();
490 490
 		$dbname = $this->getResourceName();
491
-		$conn = $dbm->acquire( $dbname );
491
+		$conn = $dbm->acquire($dbname);
492 492
 		$map = [];
493 493
 
494 494
 		try
@@ -496,27 +496,27 @@  discard block
 block discarded – undo
496 496
 			$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
497 497
 			$cfgPathSearch = 'mshop/customer/manager/fosuser/search';
498 498
 			$cfgPathCount = 'mshop/customer/manager/fosuser/count';
499
-			$required = array( 'customer' );
499
+			$required = array('customer');
500 500
 
501
-			$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
502
-			while( ( $row = $results->fetch() ) !== false ) {
503
-				$map[ $row['customer.id'] ] = $row;
501
+			$results = $this->searchItemsBase($conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level);
502
+			while (($row = $results->fetch()) !== false) {
503
+				$map[$row['customer.id']] = $row;
504 504
 			}
505 505
 
506
-			$dbm->release( $conn, $dbname );
506
+			$dbm->release($conn, $dbname);
507 507
 		}
508
-		catch( \Exception $e )
508
+		catch (\Exception $e)
509 509
 		{
510
-			$dbm->release( $conn, $dbname  );
510
+			$dbm->release($conn, $dbname);
511 511
 			throw $e;
512 512
 		}
513 513
 
514 514
 		$addrItems = [];
515
-		if( in_array( 'customer/address', $ref, true ) ) {
516
-			$addrItems = $this->getAddressItems( array_keys( $map ) );
515
+		if (in_array('customer/address', $ref, true)) {
516
+			$addrItems = $this->getAddressItems(array_keys($map));
517 517
 		}
518 518
 
519
-		return $this->buildItems( $map, $ref, 'customer', $addrItems );
519
+		return $this->buildItems($map, $ref, 'customer', $addrItems);
520 520
 	}
521 521
 
522 522
 
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
528 528
 	 * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.
529 529
 	 */
530
-	public function getSubManager( $manager, $name = null )
530
+	public function getSubManager($manager, $name = null)
531 531
 	{
532
-		return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'FosUser' : $name ) );
532
+		return $this->getSubManagerBase('customer', $manager, ($name === null ? 'FosUser' : $name));
533 533
 	}
534 534
 
535 535
 
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
 	 * @param array $refItems Items referenced by the customer item via the list items
542 542
 	 * @return \Aimeos\MShop\Customer\Item\Iface New customer item
543 543
 	 */
544
-	protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [], array $addresses = [] )
544
+	protected function createItemBase(array $values = [], array $listItems = [], array $refItems = [], array $addresses = [])
545 545
 	{
546
-		if( !isset( $this->addressManager ) ) {
547
-			$this->addressManager = $this->getObject()->getSubManager( 'address' );
546
+		if (!isset($this->addressManager)) {
547
+			$this->addressManager = $this->getObject()->getSubManager('address');
548 548
 		}
549 549
 
550
-		if( isset( $values['roles'] ) ) {
551
-			$values['roles'] = unserialize( $values['roles'] );
550
+		if (isset($values['roles'])) {
551
+			$values['roles'] = unserialize($values['roles']);
552 552
 		}
553 553
 
554 554
 		$helper = $this->getPasswordHelper();
555 555
 		$address = $this->addressManager->createItem();
556 556
 
557
-		return new \Aimeos\MShop\Customer\Item\FosUser( $address, $values, $listItems, $refItems, null, $helper, $addresses );
557
+		return new \Aimeos\MShop\Customer\Item\FosUser($address, $values, $listItems, $refItems, null, $helper, $addresses);
558 558
 	}
559 559
 }
Please login to merge, or discard this patch.
lib/custom/tests/MShop/Customer/Manager/FosUserTest.php 1 patch
Spacing   +151 added lines, -151 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,61 +85,61 @@  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 testCreateSearch()
141 141
 	{
142
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $this->object->createSearch() );
142
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $this->object->createSearch());
143 143
 	}
144 144
 
145 145
 
@@ -149,69 +149,69 @@  discard block
 block discarded – undo
149 149
 		$search = $this->object->createSearch();
150 150
 
151 151
 		$expr = [];
152
-		$expr[] = $search->compare( '!=', 'customer.id', null );
153
-		$expr[] = $search->compare( '==', 'customer.label', 'UTC002' );
154
-		$expr[] = $search->compare( '==', 'customer.code', 'UTC002' );
155
-
156
-		$expr[] = $search->compare( '>=', 'customer.salutation', '' );
157
-		$expr[] = $search->compare( '>=', 'customer.company', '' );
158
-		$expr[] = $search->compare( '>=', 'customer.vatid', '' );
159
-		$expr[] = $search->compare( '>=', 'customer.title', '' );
160
-		$expr[] = $search->compare( '>=', 'customer.firstname', '' );
161
-		$expr[] = $search->compare( '>=', 'customer.lastname', '' );
162
-		$expr[] = $search->compare( '>=', 'customer.address1', '' );
163
-		$expr[] = $search->compare( '>=', 'customer.address2', '' );
164
-		$expr[] = $search->compare( '>=', 'customer.address3', '' );
165
-		$expr[] = $search->compare( '>=', 'customer.postal', '' );
166
-		$expr[] = $search->compare( '>=', 'customer.city', '' );
167
-		$expr[] = $search->compare( '>=', 'customer.state', '' );
168
-		$expr[] = $search->compare( '!=', 'customer.languageid', null );
169
-		$expr[] = $search->compare( '>=', 'customer.countryid', '' );
170
-		$expr[] = $search->compare( '>=', 'customer.telephone', '' );
171
-		$expr[] = $search->compare( '>=', 'customer.email', '' );
172
-		$expr[] = $search->compare( '>=', 'customer.telefax', '' );
173
-		$expr[] = $search->compare( '>=', 'customer.website', '' );
174
-		$expr[] = $search->compare( '>=', 'customer.longitude', '10.0' );
175
-		$expr[] = $search->compare( '>=', 'customer.latitude', '50.0' );
176
-
177
-		$expr[] = $search->compare( '==', 'customer.birthday', '1970-01-01' );
178
-		$expr[] = $search->compare( '>=', 'customer.password', '' );
179
-		$expr[] = $search->compare( '==', 'customer.status', 0 );
180
-		$expr[] = $search->compare( '!=', 'customer.mtime', '1970-01-01 00:00:00' );
181
-		$expr[] = $search->compare( '!=', 'customer.ctime', '1970-01-01 00:00:00' );
182
-		$expr[] = $search->compare( '==', 'customer.editor', $this->editor );
183
-
184
-		$expr[] = $search->compare( '!=', 'customer.address.id', null );
185
-		$expr[] = $search->compare( '!=', 'customer.address.parentid', null );
186
-		$expr[] = $search->compare( '==', 'customer.address.company', 'ABC GmbH' );
187
-		$expr[] = $search->compare( '==', 'customer.address.vatid', 'DE999999999' );
188
-		$expr[] = $search->compare( '==', 'customer.address.salutation', 'mr' );
189
-		$expr[] = $search->compare( '==', 'customer.address.title', 'Dr.' );
190
-		$expr[] = $search->compare( '==', 'customer.address.firstname', 'Good' );
191
-		$expr[] = $search->compare( '==', 'customer.address.lastname', 'Unittest' );
192
-		$expr[] = $search->compare( '==', 'customer.address.address1', 'Pickhuben' );
193
-		$expr[] = $search->compare( '==', 'customer.address.address2', '2-4' );
194
-		$expr[] = $search->compare( '==', 'customer.address.address3', '' );
195
-		$expr[] = $search->compare( '==', 'customer.address.postal', '11099' );
196
-		$expr[] = $search->compare( '==', 'customer.address.city', 'Berlin' );
197
-		$expr[] = $search->compare( '==', 'customer.address.state', 'Berlin' );
198
-		$expr[] = $search->compare( '==', 'customer.address.languageid', 'de' );
199
-		$expr[] = $search->compare( '==', 'customer.address.countryid', 'DE' );
200
-		$expr[] = $search->compare( '==', 'customer.address.telephone', '055544332221' );
201
-		$expr[] = $search->compare( '==', 'customer.address.email', '[email protected]' );
202
-		$expr[] = $search->compare( '==', 'customer.address.telefax', '055544333212' );
203
-		$expr[] = $search->compare( '==', 'customer.address.website', 'unittest.aimeos.org' );
204
-		$expr[] = $search->compare( '>=', 'customer.address.longitude', '10.0' );
205
-		$expr[] = $search->compare( '>=', 'customer.address.latitude', '50.0' );
206
-		$expr[] = $search->compare( '==', 'customer.address.flag', 0 );
207
-		$expr[] = $search->compare( '==', 'customer.address.position', 1 );
208
-		$expr[] = $search->compare( '!=', 'customer.address.mtime', '1970-01-01 00:00:00' );
209
-		$expr[] = $search->compare( '!=', 'customer.address.ctime', '1970-01-01 00:00:00' );
210
-		$expr[] = $search->compare( '==', 'customer.address.editor', $this->editor );
211
-
212
-		$search->setConditions( $search->combine( '&&', $expr ) );
213
-		$result = $this->object->searchItems( $search, [], $total );
214
-		$this->assertEquals( 1, count( $result ) );
152
+		$expr[] = $search->compare('!=', 'customer.id', null);
153
+		$expr[] = $search->compare('==', 'customer.label', 'UTC002');
154
+		$expr[] = $search->compare('==', 'customer.code', 'UTC002');
155
+
156
+		$expr[] = $search->compare('>=', 'customer.salutation', '');
157
+		$expr[] = $search->compare('>=', 'customer.company', '');
158
+		$expr[] = $search->compare('>=', 'customer.vatid', '');
159
+		$expr[] = $search->compare('>=', 'customer.title', '');
160
+		$expr[] = $search->compare('>=', 'customer.firstname', '');
161
+		$expr[] = $search->compare('>=', 'customer.lastname', '');
162
+		$expr[] = $search->compare('>=', 'customer.address1', '');
163
+		$expr[] = $search->compare('>=', 'customer.address2', '');
164
+		$expr[] = $search->compare('>=', 'customer.address3', '');
165
+		$expr[] = $search->compare('>=', 'customer.postal', '');
166
+		$expr[] = $search->compare('>=', 'customer.city', '');
167
+		$expr[] = $search->compare('>=', 'customer.state', '');
168
+		$expr[] = $search->compare('!=', 'customer.languageid', null);
169
+		$expr[] = $search->compare('>=', 'customer.countryid', '');
170
+		$expr[] = $search->compare('>=', 'customer.telephone', '');
171
+		$expr[] = $search->compare('>=', 'customer.email', '');
172
+		$expr[] = $search->compare('>=', 'customer.telefax', '');
173
+		$expr[] = $search->compare('>=', 'customer.website', '');
174
+		$expr[] = $search->compare('>=', 'customer.longitude', '10.0');
175
+		$expr[] = $search->compare('>=', 'customer.latitude', '50.0');
176
+
177
+		$expr[] = $search->compare('==', 'customer.birthday', '1970-01-01');
178
+		$expr[] = $search->compare('>=', 'customer.password', '');
179
+		$expr[] = $search->compare('==', 'customer.status', 0);
180
+		$expr[] = $search->compare('!=', 'customer.mtime', '1970-01-01 00:00:00');
181
+		$expr[] = $search->compare('!=', 'customer.ctime', '1970-01-01 00:00:00');
182
+		$expr[] = $search->compare('==', 'customer.editor', $this->editor);
183
+
184
+		$expr[] = $search->compare('!=', 'customer.address.id', null);
185
+		$expr[] = $search->compare('!=', 'customer.address.parentid', null);
186
+		$expr[] = $search->compare('==', 'customer.address.company', 'ABC GmbH');
187
+		$expr[] = $search->compare('==', 'customer.address.vatid', 'DE999999999');
188
+		$expr[] = $search->compare('==', 'customer.address.salutation', 'mr');
189
+		$expr[] = $search->compare('==', 'customer.address.title', 'Dr.');
190
+		$expr[] = $search->compare('==', 'customer.address.firstname', 'Good');
191
+		$expr[] = $search->compare('==', 'customer.address.lastname', 'Unittest');
192
+		$expr[] = $search->compare('==', 'customer.address.address1', 'Pickhuben');
193
+		$expr[] = $search->compare('==', 'customer.address.address2', '2-4');
194
+		$expr[] = $search->compare('==', 'customer.address.address3', '');
195
+		$expr[] = $search->compare('==', 'customer.address.postal', '11099');
196
+		$expr[] = $search->compare('==', 'customer.address.city', 'Berlin');
197
+		$expr[] = $search->compare('==', 'customer.address.state', 'Berlin');
198
+		$expr[] = $search->compare('==', 'customer.address.languageid', 'de');
199
+		$expr[] = $search->compare('==', 'customer.address.countryid', 'DE');
200
+		$expr[] = $search->compare('==', 'customer.address.telephone', '055544332221');
201
+		$expr[] = $search->compare('==', 'customer.address.email', '[email protected]');
202
+		$expr[] = $search->compare('==', 'customer.address.telefax', '055544333212');
203
+		$expr[] = $search->compare('==', 'customer.address.website', 'unittest.aimeos.org');
204
+		$expr[] = $search->compare('>=', 'customer.address.longitude', '10.0');
205
+		$expr[] = $search->compare('>=', 'customer.address.latitude', '50.0');
206
+		$expr[] = $search->compare('==', 'customer.address.flag', 0);
207
+		$expr[] = $search->compare('==', 'customer.address.position', 1);
208
+		$expr[] = $search->compare('!=', 'customer.address.mtime', '1970-01-01 00:00:00');
209
+		$expr[] = $search->compare('!=', 'customer.address.ctime', '1970-01-01 00:00:00');
210
+		$expr[] = $search->compare('==', 'customer.address.editor', $this->editor);
211
+
212
+		$search->setConditions($search->combine('&&', $expr));
213
+		$result = $this->object->searchItems($search, [], $total);
214
+		$this->assertEquals(1, count($result));
215 215
 	}
216 216
 
217 217
 
@@ -220,60 +220,60 @@  discard block
 block discarded – undo
220 220
 		$total = 0;
221 221
 
222 222
 		$search = $this->object->createSearch();
223
-		$search->setConditions( $search->compare( '==', 'customer.address.editor', $this->editor ) );
224
-		$search->setSlice( 0, 2 );
223
+		$search->setConditions($search->compare('==', 'customer.address.editor', $this->editor));
224
+		$search->setSlice(0, 2);
225 225
 
226
-		$results = $this->object->searchItems( $search, [], $total );
227
-		$this->assertEquals( 2, count( $results ) );
228
-		$this->assertEquals( 3, $total );
226
+		$results = $this->object->searchItems($search, [], $total);
227
+		$this->assertEquals(2, count($results));
228
+		$this->assertEquals(3, $total);
229 229
 
230
-		foreach($results as $itemId => $item) {
231
-			$this->assertEquals( $itemId, $item->getId() );
230
+		foreach ($results as $itemId => $item) {
231
+			$this->assertEquals($itemId, $item->getId());
232 232
 		}
233 233
 	}
234 234
 
235 235
 
236 236
 	public function testSearchItemsCriteria()
237 237
 	{
238
-		$search = $this->object->createSearch( true );
238
+		$search = $this->object->createSearch(true);
239 239
 		$conditions = array(
240
-			$search->compare( '==', 'customer.address.editor', $this->editor ),
240
+			$search->compare('==', 'customer.address.editor', $this->editor),
241 241
 			$search->getConditions()
242 242
 		);
243
-		$search->setConditions( $search->combine( '&&', $conditions ) );
244
-		$this->assertEquals( 2, count( $this->object->searchItems( $search, [], $total ) ) );
243
+		$search->setConditions($search->combine('&&', $conditions));
244
+		$this->assertEquals(2, count($this->object->searchItems($search, [], $total)));
245 245
 	}
246 246
 
247 247
 
248 248
 	public function testSearchItemsRef()
249 249
 	{
250 250
 		$search = $this->object->createSearch();
251
-		$search->setConditions( $search->compare( '==', 'customer.code', 'UTC001' ) );
251
+		$search->setConditions($search->compare('==', 'customer.code', 'UTC001'));
252 252
 
253
-		$results = $this->object->searchItems( $search, ['customer/address', 'text'] );
253
+		$results = $this->object->searchItems($search, ['customer/address', 'text']);
254 254
 
255
-		if( ( $item = reset( $results ) ) === false ) {
256
-			throw new \Exception( 'No customer item for "UTC001" available' );
255
+		if (($item = reset($results)) === false) {
256
+			throw new \Exception('No customer item for "UTC001" available');
257 257
 		}
258 258
 
259
-		$this->assertEquals( 1, count( $item->getRefItems( 'text' ) ) );
260
-		$this->assertEquals( 1, count( $item->getAddressItems() ) );
259
+		$this->assertEquals(1, count($item->getRefItems('text')));
260
+		$this->assertEquals(1, count($item->getAddressItems()));
261 261
 	}
262 262
 
263 263
 
264 264
 	public function testGetSubManager()
265 265
 	{
266
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager( 'address' ) );
267
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager( 'address', 'Standard' ) );
266
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager('address'));
267
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager('address', 'Standard'));
268 268
 
269
-		$this->setExpectedException( '\\Aimeos\\MShop\\Exception' );
270
-		$this->object->getSubManager( 'unknown' );
269
+		$this->setExpectedException('\\Aimeos\\MShop\\Exception');
270
+		$this->object->getSubManager('unknown');
271 271
 	}
272 272
 
273 273
 
274 274
 	public function testGetSubManagerInvalidName()
275 275
 	{
276
-		$this->setExpectedException( '\\Aimeos\\MShop\\Exception' );
277
-		$this->object->getSubManager( 'address', 'unknown' );
276
+		$this->setExpectedException('\\Aimeos\\MShop\\Exception');
277
+		$this->object->getSubManager('address', 'unknown');
278 278
 	}
279 279
 }
Please login to merge, or discard this patch.