| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Aimeos (aimeos.org), 2015-2018 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace Aimeos\MShop\Common\Manager\Group; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class Typo3Test extends \PHPUnit\Framework\TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	private $object = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	private $editor = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	protected function setUp() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		$context = \TestHelper::getContext(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		$this->editor = $context->getEditor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		$this->object = new \Aimeos\MShop\Customer\Manager\Group\Typo3( $context ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	protected function tearDown() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 		unset( $this->object ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	public function testClear() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 		$this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->clear( array( -1 ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	public function testCreateItem() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		$item = $this->object->createItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Group\Iface::class, $item ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	public function testCreateSearch() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		$this->assertInstanceOf( \Aimeos\MW\Criteria\Iface::class, $this->object->createSearch() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	public function testDeleteItems() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		$this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->deleteItems( [-1] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	public function testGetResourceType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		$this->assertContains( 'customer/group', $this->object->getResourceType() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	public function testGetSearchAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		foreach( $this->object->getSearchAttributes() as $attribute ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 			$this->assertInstanceOf( \Aimeos\MW\Criteria\Attribute\Iface::class, $attribute ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	public function testFindItem() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		$item = $this->object->findItem( 'unitgroup' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 		$this->assertEquals( 'unitgroup', $item->getCode() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	public function testGetItem() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		$item = $this->object->findItem( 'unitgroup' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		$this->assertEquals( $item, $this->object->getItem( $item->getId() ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  | 	public function testSaveUpdateDeleteItem() | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  | 		$item = $this->object->createItem(); | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  | 		$item->setCode( 'unittest-group' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  | 		$resultSaved = $this->object->saveItem( $item ); | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  | 		$itemSaved = $this->object->getItem( $item->getId() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  | 		$itemExp = clone $itemSaved; | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  | 		$itemExp->setCode( 'unittest-group-2' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  | 		$resultUpd = $this->object->saveItem( $itemExp ); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  | 		$itemUpd = $this->object->getItem( $itemExp->getId() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  | 		$this->object->deleteItem( $itemSaved->getId() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  | 		$this->assertTrue( $item->getId() !== null ); | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  | 		$this->assertEquals( $item->getId(), $itemSaved->getId() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  | 		$this->assertEquals( $item->getCode(), $itemSaved->getCode() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  | 		$this->assertEquals( $item->getLabel(), $itemSaved->getLabel() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  | 		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeCreated() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  | 		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeModified() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  | 		$this->assertEquals( $itemExp->getId(), $itemUpd->getId() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  | 		$this->assertEquals( $itemExp->getCode(), $itemUpd->getCode() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  | 		$this->assertEquals( $itemExp->getLabel(), $itemUpd->getLabel() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  | 		$this->assertEquals( $itemExp->getTimeCreated(), $itemUpd->getTimeCreated() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  | 		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemUpd->getTimeModified() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  | 		$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultSaved ); | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  | 		$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultUpd ); | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  | 		$this->expectException( \Aimeos\MShop\Exception::class ); | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  | 		$this->object->getItem( $itemSaved->getId() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 	public function testSearchItem() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 		$search = $this->object->createSearch(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 		$search->setConditions( $search->compare( '==', 'customer.group.label', 'Unitgroup' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 		$search->setSlice( 0, 1 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		$total = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 		$results = $this->object->searchItems( $search, [], $total ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 		$this->assertEquals( 1, count( $results ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 		$this->assertEquals( 1, $total ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 141 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 142 |  |  |  |