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