@@ -4,7 +4,7 @@ |
||
| 4 | 4 | 'frontend' => array( |
| 5 | 5 | 'basket' => array( |
| 6 | 6 | 'decorators' => array( |
| 7 | - 'local' => array( 'Category', 'Stock' ), |
|
| 7 | + 'local' => array('Category', 'Stock'), |
|
| 8 | 8 | ), |
| 9 | 9 | ), |
| 10 | 10 | ), |
@@ -17,92 +17,92 @@ |
||
| 17 | 17 | { |
| 18 | 18 | public function testCreateController() |
| 19 | 19 | { |
| 20 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), 'basket' ); |
|
| 21 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Frontend\\Iface', $controller ); |
|
| 20 | + $controller = \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), 'basket'); |
|
| 21 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Frontend\\Iface', $controller); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | public function testCreateControllerEmpty() |
| 26 | 26 | { |
| 27 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
| 28 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), "\t\n" ); |
|
| 27 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
| 28 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), "\t\n"); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | public function testCreateControllerInvalidName() |
| 33 | 33 | { |
| 34 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
| 35 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), '%^' ); |
|
| 34 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
| 35 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), '%^'); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | public function testCreateControllerNotExisting() |
| 40 | 40 | { |
| 41 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
| 42 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), 'notexist' ); |
|
| 41 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
| 42 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), 'notexist'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | public function testCreateSubControllerNotExisting() |
| 47 | 47 | { |
| 48 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
| 49 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), 'basket/notexist' ); |
|
| 48 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
| 49 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), 'basket/notexist'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | public function testClear() |
| 54 | 54 | { |
| 55 | - $cache = \Aimeos\Controller\Frontend\Factory::setCache( true ); |
|
| 55 | + $cache = \Aimeos\Controller\Frontend\Factory::setCache(true); |
|
| 56 | 56 | |
| 57 | 57 | $context = \TestHelperFrontend::getContext(); |
| 58 | 58 | |
| 59 | - $controller1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 59 | + $controller1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
| 60 | 60 | \Aimeos\Controller\Frontend\Factory::clear(); |
| 61 | - $controller2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 61 | + $controller2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
| 62 | 62 | |
| 63 | - \Aimeos\Controller\Frontend\Factory::setCache( $cache ); |
|
| 63 | + \Aimeos\Controller\Frontend\Factory::setCache($cache); |
|
| 64 | 64 | |
| 65 | - $this->assertNotSame( $controller1, $controller2 ); |
|
| 65 | + $this->assertNotSame($controller1, $controller2); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | public function testClearSite() |
| 70 | 70 | { |
| 71 | - $cache = \Aimeos\Controller\Frontend\Factory::setCache( true ); |
|
| 71 | + $cache = \Aimeos\Controller\Frontend\Factory::setCache(true); |
|
| 72 | 72 | |
| 73 | 73 | $context = \TestHelperFrontend::getContext(); |
| 74 | 74 | |
| 75 | - $basket1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 76 | - $catalog1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
| 77 | - \Aimeos\Controller\Frontend\Factory::clear( (string) $context ); |
|
| 75 | + $basket1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
| 76 | + $catalog1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
| 77 | + \Aimeos\Controller\Frontend\Factory::clear((string) $context); |
|
| 78 | 78 | |
| 79 | - $basket2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 80 | - $catalog2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
| 79 | + $basket2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
| 80 | + $catalog2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
| 81 | 81 | |
| 82 | - \Aimeos\Controller\Frontend\Factory::setCache( $cache ); |
|
| 82 | + \Aimeos\Controller\Frontend\Factory::setCache($cache); |
|
| 83 | 83 | |
| 84 | - $this->assertNotSame( $basket1, $basket2 ); |
|
| 85 | - $this->assertNotSame( $catalog1, $catalog2 ); |
|
| 84 | + $this->assertNotSame($basket1, $basket2); |
|
| 85 | + $this->assertNotSame($catalog1, $catalog2); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | public function testClearSpecific() |
| 90 | 90 | { |
| 91 | - $cache = \Aimeos\Controller\Frontend\Factory::setCache( true ); |
|
| 91 | + $cache = \Aimeos\Controller\Frontend\Factory::setCache(true); |
|
| 92 | 92 | |
| 93 | 93 | $context = \TestHelperFrontend::getContext(); |
| 94 | 94 | |
| 95 | - $basket1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 96 | - $catalog1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
| 97 | - \Aimeos\Controller\Frontend\Factory::clear( (string) $context, 'basket' ); |
|
| 95 | + $basket1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
| 96 | + $catalog1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
| 97 | + \Aimeos\Controller\Frontend\Factory::clear((string) $context, 'basket'); |
|
| 98 | 98 | |
| 99 | - $basket2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 100 | - $catalog2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
| 99 | + $basket2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
| 100 | + $catalog2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
| 101 | 101 | |
| 102 | - \Aimeos\Controller\Frontend\Factory::setCache( $cache ); |
|
| 102 | + \Aimeos\Controller\Frontend\Factory::setCache($cache); |
|
| 103 | 103 | |
| 104 | - $this->assertNotSame( $basket1, $basket2 ); |
|
| 105 | - $this->assertSame( $catalog1, $catalog2 ); |
|
| 104 | + $this->assertNotSame($basket1, $basket2); |
|
| 105 | + $this->assertSame($catalog1, $catalog2); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | \ No newline at end of file |
@@ -18,18 +18,18 @@ discard block |
||
| 18 | 18 | protected function setUp() |
| 19 | 19 | { |
| 20 | 20 | $this->context = \TestHelperFrontend::getContext(); |
| 21 | - $this->testItem = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
| 21 | + $this->testItem = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
| 22 | 22 | |
| 23 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 23 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | protected function tearDown() |
| 28 | 28 | { |
| 29 | 29 | $this->object->clear(); |
| 30 | - $this->context->getSession()->set( 'aimeos', array() ); |
|
| 30 | + $this->context->getSession()->set('aimeos', array()); |
|
| 31 | 31 | |
| 32 | - unset( $this->object, $this->testItem ); |
|
| 32 | + unset($this->object, $this->testItem); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -38,457 +38,457 @@ discard block |
||
| 38 | 38 | $basket = $this->object->get(); |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
| 41 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
| 42 | 42 | |
| 43 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 44 | - $this->assertEquals( 2, $basket->getProduct( 0 )->getQuantity() ); |
|
| 45 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
| 43 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 44 | + $this->assertEquals(2, $basket->getProduct(0)->getQuantity()); |
|
| 45 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 48 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 49 | 49 | |
| 50 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'default' ); |
|
| 51 | - $item2 = $this->object->get()->getProduct( 1 ); |
|
| 52 | - $this->object->deleteProduct( 0 ); |
|
| 50 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'default'); |
|
| 51 | + $item2 = $this->object->get()->getProduct(1); |
|
| 52 | + $this->object->deleteProduct(0); |
|
| 53 | 53 | |
| 54 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 55 | - $this->assertEquals( $item2, $basket->getProduct( 1 ) ); |
|
| 56 | - $this->assertEquals( 'CNC', $basket->getProduct( 1 )->getProductCode() ); |
|
| 54 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 55 | + $this->assertEquals($item2, $basket->getProduct(1)); |
|
| 56 | + $this->assertEquals('CNC', $basket->getProduct(1)->getProductCode()); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | public function testAddProductBundle() |
| 61 | 61 | { |
| 62 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:BUNDLE' ); |
|
| 62 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:BUNDLE'); |
|
| 63 | 63 | |
| 64 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 64 | + $this->object->addProduct($item->getId(), 1); |
|
| 65 | 65 | |
| 66 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
| 67 | - $this->assertEquals( 'U:BUNDLE', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 68 | - $this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getProducts() ) ); |
|
| 66 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
| 67 | + $this->assertEquals('U:BUNDLE', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 68 | + $this->assertEquals(2, count($this->object->get()->getProduct(0)->getProducts())); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | public function testAddProductVariant() |
| 73 | 73 | { |
| 74 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 74 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 75 | 75 | |
| 76 | 76 | $search = $attributeManager->createSearch(); |
| 77 | - $search->setConditions( $search->compare( '==', 'attribute.code', array( 'xs', 'white' ) ) ); |
|
| 77 | + $search->setConditions($search->compare('==', 'attribute.code', array('xs', 'white'))); |
|
| 78 | 78 | |
| 79 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 79 | + $attributes = $attributeManager->searchItems($search); |
|
| 80 | 80 | |
| 81 | - if( count( $attributes ) === 0 ) { |
|
| 82 | - throw new \Exception( 'Attributes not found' ); |
|
| 81 | + if (count($attributes) === 0) { |
|
| 82 | + throw new \Exception('Attributes not found'); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
| 86 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 86 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 87 | 87 | |
| 88 | - $this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ), array(), array(), array(), 'default' ); |
|
| 88 | + $this->object->addProduct($item->getId(), 1, array(), array_keys($attributes), array(), array(), array(), 'default'); |
|
| 89 | 89 | |
| 90 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
| 91 | - $this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 90 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
| 91 | + $this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | public function testAddProductVariantIncomplete() |
| 96 | 96 | { |
| 97 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 97 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 98 | 98 | |
| 99 | 99 | $search = $attributeManager->createSearch(); |
| 100 | 100 | $expr = array( |
| 101 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 102 | - $search->compare( '==', 'attribute.code', '30' ), |
|
| 103 | - $search->compare( '==', 'attribute.type.code', 'length' ), |
|
| 101 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 102 | + $search->compare('==', 'attribute.code', '30'), |
|
| 103 | + $search->compare('==', 'attribute.type.code', 'length'), |
|
| 104 | 104 | ); |
| 105 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 105 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 106 | 106 | |
| 107 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 107 | + $attributes = $attributeManager->searchItems($search); |
|
| 108 | 108 | |
| 109 | - if( count( $attributes ) === 0 ) { |
|
| 110 | - throw new \Exception( 'Attributes not found' ); |
|
| 109 | + if (count($attributes) === 0) { |
|
| 110 | + throw new \Exception('Attributes not found'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
| 114 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' ); |
|
| 114 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST'); |
|
| 115 | 115 | |
| 116 | - $this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ) ); |
|
| 116 | + $this->object->addProduct($item->getId(), 1, array(), array_keys($attributes)); |
|
| 117 | 117 | |
| 118 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
| 119 | - $this->assertEquals( 'U:TESTSUB02', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 120 | - $this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getAttributes() ) ); |
|
| 118 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
| 119 | + $this->assertEquals('U:TESTSUB02', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 120 | + $this->assertEquals(2, count($this->object->get()->getProduct(0)->getAttributes())); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | public function testAddProductVariantNonUnique() |
| 125 | 125 | { |
| 126 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 126 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 127 | 127 | |
| 128 | 128 | $search = $attributeManager->createSearch(); |
| 129 | 129 | $expr = array( |
| 130 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 131 | - $search->compare( '==', 'attribute.code', '30' ), |
|
| 132 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
| 130 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 131 | + $search->compare('==', 'attribute.code', '30'), |
|
| 132 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
| 133 | 133 | ); |
| 134 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 134 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 135 | 135 | |
| 136 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 136 | + $attributes = $attributeManager->searchItems($search); |
|
| 137 | 137 | |
| 138 | - if( count( $attributes ) === 0 ) { |
|
| 139 | - throw new \Exception( 'Attributes not found' ); |
|
| 138 | + if (count($attributes) === 0) { |
|
| 139 | + throw new \Exception('Attributes not found'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' ); |
|
| 143 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST'); |
|
| 144 | 144 | |
| 145 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 146 | - $this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ) ); |
|
| 145 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 146 | + $this->object->addProduct($item->getId(), 1, array(), array_keys($attributes)); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | public function testAddProductVariantNotRequired() |
| 151 | 151 | { |
| 152 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 152 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 153 | 153 | |
| 154 | 154 | $search = $attributeManager->createSearch(); |
| 155 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
| 155 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
| 156 | 156 | |
| 157 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 157 | + $attributes = $attributeManager->searchItems($search); |
|
| 158 | 158 | |
| 159 | - if( count( $attributes ) === 0 ) { |
|
| 160 | - throw new \Exception( 'Attribute not found' ); |
|
| 159 | + if (count($attributes) === 0) { |
|
| 160 | + throw new \Exception('Attribute not found'); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $options = array( 'variant' => false ); |
|
| 163 | + $options = array('variant' => false); |
|
| 164 | 164 | |
| 165 | - $this->object->addProduct( $this->testItem->getId(), 1, $options, array_keys( $attributes ) ); |
|
| 165 | + $this->object->addProduct($this->testItem->getId(), 1, $options, array_keys($attributes)); |
|
| 166 | 166 | |
| 167 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
| 168 | - $this->assertEquals( 'U:TESTP', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 167 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
| 168 | + $this->assertEquals('U:TESTP', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | public function testAddProductConfigAttribute() |
| 173 | 173 | { |
| 174 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 174 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 175 | 175 | |
| 176 | 176 | $search = $attributeManager->createSearch(); |
| 177 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
| 177 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
| 178 | 178 | |
| 179 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 179 | + $attributes = $attributeManager->searchItems($search); |
|
| 180 | 180 | |
| 181 | - if( empty( $attributes ) ) { |
|
| 182 | - throw new \Exception( 'Attribute not found' ); |
|
| 181 | + if (empty($attributes)) { |
|
| 182 | + throw new \Exception('Attribute not found'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array_keys( $attributes ) ); |
|
| 185 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array_keys($attributes)); |
|
| 186 | 186 | $basket = $this->object->get(); |
| 187 | 187 | |
| 188 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 189 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
| 190 | - $this->assertEquals( 'xs', $basket->getProduct( 0 )->getAttribute( 'size', 'config' ) ); |
|
| 188 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 189 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
| 190 | + $this->assertEquals('xs', $basket->getProduct(0)->getAttribute('size', 'config')); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
| 194 | 194 | public function testAddProductHiddenAttribute() |
| 195 | 195 | { |
| 196 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 196 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 197 | 197 | |
| 198 | 198 | $search = $attributeManager->createSearch(); |
| 199 | 199 | $expr = array( |
| 200 | - $search->compare( '==', 'attribute.code', '29' ), |
|
| 201 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
| 200 | + $search->compare('==', 'attribute.code', '29'), |
|
| 201 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
| 202 | 202 | ); |
| 203 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 203 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 204 | 204 | |
| 205 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 205 | + $attributes = $attributeManager->searchItems($search); |
|
| 206 | 206 | |
| 207 | - if( empty( $attributes ) ) { |
|
| 208 | - throw new \Exception( 'Attribute not found' ); |
|
| 207 | + if (empty($attributes)) { |
|
| 208 | + throw new \Exception('Attribute not found'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array(), array_keys( $attributes ) ); |
|
| 211 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array(), array_keys($attributes)); |
|
| 212 | 212 | |
| 213 | 213 | $basket = $this->object->get(); |
| 214 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 214 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 215 | 215 | |
| 216 | - $product = $basket->getProduct( 0 ); |
|
| 217 | - $this->assertEquals( 'U:TESTPSUB01', $product->getProductCode() ); |
|
| 216 | + $product = $basket->getProduct(0); |
|
| 217 | + $this->assertEquals('U:TESTPSUB01', $product->getProductCode()); |
|
| 218 | 218 | |
| 219 | 219 | $attributes = $product->getAttributes(); |
| 220 | - $this->assertEquals( 1, count( $attributes ) ); |
|
| 220 | + $this->assertEquals(1, count($attributes)); |
|
| 221 | 221 | |
| 222 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
| 223 | - throw new \Exception( 'No attribute' ); |
|
| 222 | + if (($attribute = reset($attributes)) === false) { |
|
| 223 | + throw new \Exception('No attribute'); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - $this->assertEquals( 'hidden', $attribute->getType() ); |
|
| 227 | - $this->assertEquals( '29', $product->getAttribute( 'width', 'hidden' ) ); |
|
| 226 | + $this->assertEquals('hidden', $attribute->getType()); |
|
| 227 | + $this->assertEquals('29', $product->getAttribute('width', 'hidden')); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
| 231 | 231 | public function testAddProductCustomAttribute() |
| 232 | 232 | { |
| 233 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 233 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 234 | 234 | |
| 235 | 235 | $search = $attributeManager->createSearch(); |
| 236 | 236 | $expr = array( |
| 237 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 238 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
| 237 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 238 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
| 239 | 239 | ); |
| 240 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 240 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 241 | 241 | |
| 242 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 242 | + $attributes = $attributeManager->searchItems($search); |
|
| 243 | 243 | |
| 244 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 245 | - throw new \Exception( 'Attribute not found' ); |
|
| 244 | + if (($attrItem = reset($attributes)) === false) { |
|
| 245 | + throw new \Exception('Attribute not found'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
| 248 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
| 249 | 249 | |
| 250 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array(), array(), $attrValues ); |
|
| 250 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array(), array(), $attrValues); |
|
| 251 | 251 | $basket = $this->object->get(); |
| 252 | 252 | |
| 253 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 254 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
| 253 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 254 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
| 258 | 258 | public function testAddProductAttributeNotAssigned() |
| 259 | 259 | { |
| 260 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 260 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 261 | 261 | |
| 262 | 262 | $search = $attributeManager->createSearch(); |
| 263 | 263 | $expr = array( |
| 264 | - $search->compare( '==', 'attribute.code', '30' ), |
|
| 265 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
| 264 | + $search->compare('==', 'attribute.code', '30'), |
|
| 265 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
| 266 | 266 | ); |
| 267 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 267 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 268 | 268 | |
| 269 | - $attribute = $attributeManager->searchItems( $search ); |
|
| 269 | + $attribute = $attributeManager->searchItems($search); |
|
| 270 | 270 | |
| 271 | - if( empty( $attribute ) ) { |
|
| 272 | - throw new \Exception( 'Attribute not found' ); |
|
| 271 | + if (empty($attribute)) { |
|
| 272 | + throw new \Exception('Attribute not found'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $hiddenAttrIds = array_keys( $attribute ); |
|
| 276 | - $configAttrIds = array_keys( $attribute ); |
|
| 275 | + $hiddenAttrIds = array_keys($attribute); |
|
| 276 | + $configAttrIds = array_keys($attribute); |
|
| 277 | 277 | |
| 278 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 279 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), $configAttrIds, $hiddenAttrIds ); |
|
| 278 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 279 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), $configAttrIds, $hiddenAttrIds); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
| 283 | 283 | public function testAddProductNegativeQuantityException() |
| 284 | 284 | { |
| 285 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
| 286 | - $this->object->addProduct( $this->testItem->getId(), -1 ); |
|
| 285 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
| 286 | + $this->object->addProduct($this->testItem->getId(), -1); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | |
| 290 | 290 | public function testAddProductNoPriceException() |
| 291 | 291 | { |
| 292 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
| 292 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
| 293 | 293 | |
| 294 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 295 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 294 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 295 | + $this->object->addProduct($item->getId(), 1); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
| 299 | 299 | public function testAddProductConfigAttributeException() |
| 300 | 300 | { |
| 301 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 302 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array( -1 ) ); |
|
| 301 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 302 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array( -1 )); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | public function testAddProductEmptySelectionException() |
| 307 | 307 | { |
| 308 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:noSel' ); |
|
| 308 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:noSel'); |
|
| 309 | 309 | |
| 310 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 311 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 310 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 311 | + $this->object->addProduct($item->getId(), 1); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
| 315 | 315 | public function testAddProductSelectionWithPricelessItem() |
| 316 | 316 | { |
| 317 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTPSUB01' ); |
|
| 317 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTPSUB01'); |
|
| 318 | 318 | |
| 319 | - $this->object->addProduct( $this->testItem->getId(), 1 ); |
|
| 319 | + $this->object->addProduct($this->testItem->getId(), 1); |
|
| 320 | 320 | |
| 321 | - $this->assertEquals( 'U:TESTPSUB01', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 321 | + $this->assertEquals('U:TESTPSUB01', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | |
| 325 | 325 | public function testAddProductLowQuantityPriceException() |
| 326 | 326 | { |
| 327 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 327 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 328 | 328 | |
| 329 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 330 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 329 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 330 | + $this->object->addProduct($item->getId(), 1); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | |
| 334 | 334 | public function testAddProductHigherQuantities() |
| 335 | 335 | { |
| 336 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 336 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 337 | 337 | |
| 338 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
| 338 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
| 339 | 339 | |
| 340 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
| 341 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 340 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
| 341 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | |
| 345 | 345 | public function testDeleteProductFlagError() |
| 346 | 346 | { |
| 347 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
| 347 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
| 348 | 348 | |
| 349 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 350 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 349 | + $item = $this->object->get()->getProduct(0); |
|
| 350 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 351 | 351 | |
| 352 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 353 | - $this->object->deleteProduct( 0 ); |
|
| 352 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 353 | + $this->object->deleteProduct(0); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
| 357 | 357 | public function testEditProduct() |
| 358 | 358 | { |
| 359 | - $this->object->addProduct( $this->testItem->getId(), 1 ); |
|
| 359 | + $this->object->addProduct($this->testItem->getId(), 1); |
|
| 360 | 360 | |
| 361 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 362 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
| 361 | + $item = $this->object->get()->getProduct(0); |
|
| 362 | + $this->assertEquals(1, $item->getQuantity()); |
|
| 363 | 363 | |
| 364 | - $this->object->editProduct( 0, 4 ); |
|
| 364 | + $this->object->editProduct(0, 4); |
|
| 365 | 365 | |
| 366 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 367 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 368 | - $this->assertEquals( 'U:TESTPSUB01', $item->getProductCode() ); |
|
| 366 | + $item = $this->object->get()->getProduct(0); |
|
| 367 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 368 | + $this->assertEquals('U:TESTPSUB01', $item->getProductCode()); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | |
| 372 | 372 | public function testEditProductAttributes() |
| 373 | 373 | { |
| 374 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 374 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 375 | 375 | |
| 376 | 376 | $search = $attributeManager->createSearch(); |
| 377 | 377 | $conditions = array( |
| 378 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 379 | - $search->combine( '||', array( |
|
| 380 | - $search->combine( '&&', array( |
|
| 381 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
| 382 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
| 383 | - ) ), |
|
| 384 | - $search->combine( '&&', array( |
|
| 385 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
| 386 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
| 387 | - ) ), |
|
| 388 | - ) ) |
|
| 378 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 379 | + $search->combine('||', array( |
|
| 380 | + $search->combine('&&', array( |
|
| 381 | + $search->compare('==', 'attribute.code', 'xs'), |
|
| 382 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
| 383 | + )), |
|
| 384 | + $search->combine('&&', array( |
|
| 385 | + $search->compare('==', 'attribute.code', 'white'), |
|
| 386 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
| 387 | + )), |
|
| 388 | + )) |
|
| 389 | 389 | ); |
| 390 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
| 391 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 390 | + $search->setConditions($search->combine('&&', $conditions)); |
|
| 391 | + $attributes = $attributeManager->searchItems($search); |
|
| 392 | 392 | |
| 393 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
| 394 | - throw new \Exception( 'No attributes available' ); |
|
| 393 | + if (($attribute = reset($attributes)) === false) { |
|
| 394 | + throw new \Exception('No attributes available'); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | |
| 398 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
| 398 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
| 399 | 399 | |
| 400 | - $this->object->addProduct( $item->getId(), 1, array(), array(), array_keys( $attributes ) ); |
|
| 401 | - $this->object->editProduct( 0, 4 ); |
|
| 400 | + $this->object->addProduct($item->getId(), 1, array(), array(), array_keys($attributes)); |
|
| 401 | + $this->object->editProduct(0, 4); |
|
| 402 | 402 | |
| 403 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 404 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
| 405 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 403 | + $item = $this->object->get()->getProduct(0); |
|
| 404 | + $this->assertEquals(2, count($item->getAttributes())); |
|
| 405 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 406 | 406 | |
| 407 | 407 | |
| 408 | - $this->object->editProduct( 0, 3, array(), array( $attribute->getType() ) ); |
|
| 408 | + $this->object->editProduct(0, 3, array(), array($attribute->getType())); |
|
| 409 | 409 | |
| 410 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 411 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
| 412 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
| 413 | - $this->assertEquals( 'U:TESTPSUB01', $item->getProductCode() ); |
|
| 410 | + $item = $this->object->get()->getProduct(0); |
|
| 411 | + $this->assertEquals(3, $item->getQuantity()); |
|
| 412 | + $this->assertEquals(1, count($item->getAttributes())); |
|
| 413 | + $this->assertEquals('U:TESTPSUB01', $item->getProductCode()); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
| 417 | 417 | public function testEditProductFlagError() |
| 418 | 418 | { |
| 419 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
| 419 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
| 420 | 420 | |
| 421 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 422 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 421 | + $item = $this->object->get()->getProduct(0); |
|
| 422 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 423 | 423 | |
| 424 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 425 | - $this->object->editProduct( 0, 4 ); |
|
| 424 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 425 | + $this->object->editProduct(0, 4); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
| 429 | 429 | public function testAddCoupon() |
| 430 | 430 | { |
| 431 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
| 432 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 431 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
| 432 | + $this->object->addCoupon('GHIJ'); |
|
| 433 | 433 | |
| 434 | 434 | $basket = $this->object->get(); |
| 435 | 435 | |
| 436 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
| 436 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | |
| 440 | 440 | public function testAddCouponInvalidCode() |
| 441 | 441 | { |
| 442 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 443 | - $this->object->addCoupon( 'invalid' ); |
|
| 442 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 443 | + $this->object->addCoupon('invalid'); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
| 447 | 447 | public function testAddCouponMissingRequirements() |
| 448 | 448 | { |
| 449 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 450 | - $this->object->addCoupon( 'OPQR' ); |
|
| 449 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 450 | + $this->object->addCoupon('OPQR'); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | |
| 454 | 454 | public function testDeleteCoupon() |
| 455 | 455 | { |
| 456 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
| 457 | - $this->object->addCoupon( '90AB' ); |
|
| 458 | - $this->object->deleteCoupon( '90AB' ); |
|
| 456 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
| 457 | + $this->object->addCoupon('90AB'); |
|
| 458 | + $this->object->deleteCoupon('90AB'); |
|
| 459 | 459 | |
| 460 | 460 | $basket = $this->object->get(); |
| 461 | 461 | |
| 462 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
| 462 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | |
| 466 | 466 | public function testClear() |
| 467 | 467 | { |
| 468 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
| 468 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
| 469 | 469 | $this->object->clear(); |
| 470 | 470 | |
| 471 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
| 471 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | public function testSetAddressDelete() |
| 476 | 476 | { |
| 477 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
| 477 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
| 478 | 478 | |
| 479 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
| 480 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 479 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
| 480 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | |
| 484 | 484 | public function testSetBillingAddressByItem() |
| 485 | 485 | { |
| 486 | - $item = $this->getAddress( 'Example company' ); |
|
| 486 | + $item = $this->getAddress('Example company'); |
|
| 487 | 487 | |
| 488 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
| 488 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
| 489 | 489 | |
| 490 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 491 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 490 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 491 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | |
@@ -516,37 +516,37 @@ discard block |
||
| 516 | 516 | 'order.base.address.flag' => 0, |
| 517 | 517 | ); |
| 518 | 518 | |
| 519 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
| 519 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
| 520 | 520 | |
| 521 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 522 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 523 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 524 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 521 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 522 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 523 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 524 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | public function testSetBillingAddressByArrayError() |
| 529 | 529 | { |
| 530 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 531 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
| 530 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 531 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | |
| 535 | 535 | public function testSetBillingAddressParameterError() |
| 536 | 536 | { |
| 537 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 538 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
| 537 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 538 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | |
| 542 | 542 | public function testSetDeliveryAddressByItem() |
| 543 | 543 | { |
| 544 | - $item = $this->getAddress( 'Example company' ); |
|
| 544 | + $item = $this->getAddress('Example company'); |
|
| 545 | 545 | |
| 546 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
| 546 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
| 547 | 547 | |
| 548 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 549 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 548 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 549 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | |
@@ -573,119 +573,119 @@ discard block |
||
| 573 | 573 | 'order.base.address.website' => 'www.example.com', |
| 574 | 574 | 'order.base.address.flag' => 0, |
| 575 | 575 | ); |
| 576 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
| 576 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
| 577 | 577 | |
| 578 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 579 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 580 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 581 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 578 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 579 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 580 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 581 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | |
| 585 | 585 | public function testSetDeliveryAddressByArrayError() |
| 586 | 586 | { |
| 587 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 588 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
| 587 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 588 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | |
| 592 | 592 | public function testSetDeliveryAddressTypeError() |
| 593 | 593 | { |
| 594 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 595 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
| 594 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 595 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | |
| 599 | 599 | public function testSetServicePayment() |
| 600 | 600 | { |
| 601 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 602 | - $service = $manager->findItem( 'unitpaymentcode', array(), 'service', 'payment' ); |
|
| 601 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 602 | + $service = $manager->findItem('unitpaymentcode', array(), 'service', 'payment'); |
|
| 603 | 603 | |
| 604 | - $this->object->setService( 'payment', $service->getId(), array() ); |
|
| 605 | - $this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() ); |
|
| 604 | + $this->object->setService('payment', $service->getId(), array()); |
|
| 605 | + $this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode()); |
|
| 606 | 606 | |
| 607 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 608 | - $this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
| 607 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 608 | + $this->object->setService('payment', $service->getId(), array('prepay' => true)); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | |
| 612 | 612 | public function testSetDeliveryOption() |
| 613 | 613 | { |
| 614 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 615 | - $service = $manager->findItem( 'unitcode', array(), 'service', 'delivery' ); |
|
| 614 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 615 | + $service = $manager->findItem('unitcode', array(), 'service', 'delivery'); |
|
| 616 | 616 | |
| 617 | - $this->object->setService( 'delivery', $service->getId(), array() ); |
|
| 618 | - $this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() ); |
|
| 617 | + $this->object->setService('delivery', $service->getId(), array()); |
|
| 618 | + $this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode()); |
|
| 619 | 619 | |
| 620 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 621 | - $this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
| 620 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 621 | + $this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | |
| 625 | 625 | public function testCheckLocale() |
| 626 | 626 | { |
| 627 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 628 | - $payment = $manager->findItem( 'unitpaymentcode', array(), 'service', 'payment' ); |
|
| 629 | - $delivery = $manager->findItem( 'unitcode', array(), 'service', 'delivery' ); |
|
| 627 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 628 | + $payment = $manager->findItem('unitpaymentcode', array(), 'service', 'payment'); |
|
| 629 | + $delivery = $manager->findItem('unitcode', array(), 'service', 'delivery'); |
|
| 630 | 630 | |
| 631 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
| 632 | - $this->object->addCoupon( 'OPQR' ); |
|
| 631 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
| 632 | + $this->object->addCoupon('OPQR'); |
|
| 633 | 633 | |
| 634 | - $this->object->setService( 'payment', $payment->getId() ); |
|
| 635 | - $this->object->setService( 'delivery', $delivery->getId() ); |
|
| 634 | + $this->object->setService('payment', $payment->getId()); |
|
| 635 | + $this->object->setService('delivery', $delivery->getId()); |
|
| 636 | 636 | |
| 637 | 637 | $basket = $this->object->get(); |
| 638 | 638 | $price = $basket->getPrice(); |
| 639 | 639 | |
| 640 | - foreach( $basket->getProducts() as $product ) |
|
| 640 | + foreach ($basket->getProducts() as $product) |
|
| 641 | 641 | { |
| 642 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 643 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
| 642 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 643 | + $product->getPrice()->setCurrencyId('CHF'); |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 647 | - $basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 648 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
| 649 | - $price->setCurrencyId( 'CHF' ); |
|
| 646 | + $basket->getService('delivery')->getPrice()->setCurrencyId('CHF'); |
|
| 647 | + $basket->getService('payment')->getPrice()->setCurrencyId('CHF'); |
|
| 648 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
| 649 | + $price->setCurrencyId('CHF'); |
|
| 650 | 650 | |
| 651 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
| 652 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
| 651 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
| 652 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
| 653 | 653 | |
| 654 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
| 655 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
| 654 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
| 655 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
| 656 | 656 | |
| 657 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
| 657 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
| 658 | 658 | |
| 659 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 659 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 660 | 660 | $basket = $object->get(); |
| 661 | 661 | |
| 662 | - foreach( $basket->getProducts() as $product ) |
|
| 662 | + foreach ($basket->getProducts() as $product) |
|
| 663 | 663 | { |
| 664 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
| 665 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 664 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
| 665 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | - $this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() ); |
|
| 669 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() ); |
|
| 670 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
| 671 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
| 668 | + $this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId()); |
|
| 669 | + $this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId()); |
|
| 670 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
| 671 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | |
| 675 | 675 | /** |
| 676 | 676 | * @param string $company |
| 677 | 677 | */ |
| 678 | - protected function getAddress( $company ) |
|
| 678 | + protected function getAddress($company) |
|
| 679 | 679 | { |
| 680 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
| 681 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
| 680 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
| 681 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
| 682 | 682 | |
| 683 | 683 | $search = $addressManager->createSearch(); |
| 684 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
| 685 | - $items = $addressManager->searchItems( $search ); |
|
| 684 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
| 685 | + $items = $addressManager->searchItems($search); |
|
| 686 | 686 | |
| 687 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 688 | - throw new \Exception( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
| 687 | + if (($item = reset($items)) === false) { |
|
| 688 | + throw new \Exception(sprintf('No address item with company "%1$s" found', $company)); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | return $item; |
@@ -12,35 +12,35 @@ |
||
| 12 | 12 | protected function setUp() |
| 13 | 13 | { |
| 14 | 14 | $this->context = \TestHelperFrontend::getContext(); |
| 15 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 16 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Category( $object, $this->context ); |
|
| 15 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 16 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Category($object, $this->context); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | protected function tearDown() |
| 21 | 21 | { |
| 22 | 22 | $this->object->clear(); |
| 23 | - $this->context->getSession()->set( 'aimeos', array() ); |
|
| 23 | + $this->context->getSession()->set('aimeos', array()); |
|
| 24 | 24 | |
| 25 | - unset( $this->object ); |
|
| 25 | + unset($this->object); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | public function testAddProductWithCategory() |
| 30 | 30 | { |
| 31 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
|
| 32 | - $item = $manager->findItem( 'CNE' ); |
|
| 31 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); |
|
| 32 | + $item = $manager->findItem('CNE'); |
|
| 33 | 33 | |
| 34 | - $this->object->addProduct( $item->getId(), 5 ); |
|
| 34 | + $this->object->addProduct($item->getId(), 5); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | public function testAddProductNoCategory() |
| 39 | 39 | { |
| 40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
|
| 41 | - $item = $manager->findItem( 'ABCD' ); |
|
| 40 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); |
|
| 41 | + $item = $manager->findItem('ABCD'); |
|
| 42 | 42 | |
| 43 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
| 44 | - $this->object->addProduct( $item->getId(), 5 ); |
|
| 43 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
| 44 | + $this->object->addProduct($item->getId(), 5); |
|
| 45 | 45 | } |
| 46 | 46 | } |
@@ -12,132 +12,132 @@ discard block |
||
| 12 | 12 | protected function setUp() |
| 13 | 13 | { |
| 14 | 14 | $this->context = \TestHelperFrontend::getContext(); |
| 15 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 16 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Stock( $object, $this->context ); |
|
| 15 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 16 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Stock($object, $this->context); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | protected function tearDown() |
| 21 | 21 | { |
| 22 | 22 | $this->object->clear(); |
| 23 | - $this->context->getSession()->set( 'aimeos', array() ); |
|
| 23 | + $this->context->getSession()->set('aimeos', array()); |
|
| 24 | 24 | |
| 25 | - unset( $this->object ); |
|
| 25 | + unset($this->object); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | public function testAddProductNotEnoughStockException() |
| 30 | 30 | { |
| 31 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 31 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 32 | 32 | |
| 33 | 33 | $search = $productManager->createSearch(); |
| 34 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
| 34 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
| 35 | 35 | |
| 36 | - $items = $productManager->searchItems( $search ); |
|
| 36 | + $items = $productManager->searchItems($search); |
|
| 37 | 37 | |
| 38 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 39 | - throw new \Exception( 'Product not found' ); |
|
| 38 | + if (($item = reset($items)) === false) { |
|
| 39 | + throw new \Exception('Product not found'); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | try |
| 43 | 43 | { |
| 44 | - $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
| 45 | - throw new \Exception( 'Expected exception not thrown' ); |
|
| 44 | + $this->object->addProduct($item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
| 45 | + throw new \Exception('Expected exception not thrown'); |
|
| 46 | 46 | } |
| 47 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
| 47 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
| 48 | 48 | { |
| 49 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 50 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
| 49 | + $item = $this->object->get()->getProduct(0); |
|
| 50 | + $this->assertEquals(3, $item->getQuantity()); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | public function testAddProductNoStockException() |
| 56 | 56 | { |
| 57 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 57 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 58 | 58 | |
| 59 | 59 | $search = $productManager->createSearch(); |
| 60 | - $search->setConditions( $search->compare( '==', 'product.code', 'EFGH' ) ); |
|
| 60 | + $search->setConditions($search->compare('==', 'product.code', 'EFGH')); |
|
| 61 | 61 | |
| 62 | - $items = $productManager->searchItems( $search ); |
|
| 62 | + $items = $productManager->searchItems($search); |
|
| 63 | 63 | |
| 64 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 65 | - throw new \Exception( 'Product not found' ); |
|
| 64 | + if (($item = reset($items)) === false) { |
|
| 65 | + throw new \Exception('Product not found'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | try |
| 69 | 69 | { |
| 70 | - $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse2' ); |
|
| 71 | - throw new \Exception( 'Expected exception not thrown' ); |
|
| 70 | + $this->object->addProduct($item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse2'); |
|
| 71 | + throw new \Exception('Expected exception not thrown'); |
|
| 72 | 72 | } |
| 73 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
| 73 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
| 74 | 74 | { |
| 75 | - $this->assertEquals( array(), $this->object->get()->getProducts() ); |
|
| 75 | + $this->assertEquals(array(), $this->object->get()->getProducts()); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | public function testAddProductNoStockRequired() |
| 81 | 81 | { |
| 82 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 82 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 83 | 83 | |
| 84 | 84 | $search = $productManager->createSearch(); |
| 85 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
| 85 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
| 86 | 86 | |
| 87 | - $items = $productManager->searchItems( $search ); |
|
| 87 | + $items = $productManager->searchItems($search); |
|
| 88 | 88 | |
| 89 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 90 | - throw new \Exception( 'Product not found' ); |
|
| 89 | + if (($item = reset($items)) === false) { |
|
| 90 | + throw new \Exception('Product not found'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $this->object->addProduct( $item->getId(), 5, array( 'stock' => false ) ); |
|
| 93 | + $this->object->addProduct($item->getId(), 5, array('stock' => false)); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | public function testAddProductNoStockItem() |
| 98 | 98 | { |
| 99 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 99 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 100 | 100 | |
| 101 | 101 | $search = $productManager->createSearch(); |
| 102 | - $search->setConditions( $search->compare( '==', 'product.code', 'QRST' ) ); |
|
| 102 | + $search->setConditions($search->compare('==', 'product.code', 'QRST')); |
|
| 103 | 103 | |
| 104 | - $items = $productManager->searchItems( $search ); |
|
| 104 | + $items = $productManager->searchItems($search); |
|
| 105 | 105 | |
| 106 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 107 | - throw new \Exception( 'Product not found' ); |
|
| 106 | + if (($item = reset($items)) === false) { |
|
| 107 | + throw new \Exception('Product not found'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 111 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 110 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 111 | + $this->object->addProduct($item->getId(), 1); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | public function testEditProductNotEnoughStock() |
| 116 | 116 | { |
| 117 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 117 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 118 | 118 | $search = $productManager->createSearch(); |
| 119 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
| 120 | - $items = $productManager->searchItems( $search ); |
|
| 119 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
| 120 | + $items = $productManager->searchItems($search); |
|
| 121 | 121 | |
| 122 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 123 | - throw new \Exception( 'Product not found' ); |
|
| 122 | + if (($item = reset($items)) === false) { |
|
| 123 | + throw new \Exception('Product not found'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
| 126 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
| 127 | 127 | |
| 128 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 129 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
| 128 | + $item = $this->object->get()->getProduct(0); |
|
| 129 | + $this->assertEquals(2, $item->getQuantity()); |
|
| 130 | 130 | |
| 131 | 131 | try |
| 132 | 132 | { |
| 133 | - $this->object->editProduct( 0, 5 ); |
|
| 134 | - throw new \Exception( 'Expected exception not thrown' ); |
|
| 133 | + $this->object->editProduct(0, 5); |
|
| 134 | + throw new \Exception('Expected exception not thrown'); |
|
| 135 | 135 | } |
| 136 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
| 136 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
| 137 | 137 | { |
| 138 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 139 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
| 140 | - $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
| 138 | + $item = $this->object->get()->getProduct(0); |
|
| 139 | + $this->assertEquals(3, $item->getQuantity()); |
|
| 140 | + $this->assertEquals('IJKL', $item->getProductCode()); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
@@ -146,58 +146,58 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $context = \TestHelperFrontend::getContext(); |
| 148 | 148 | |
| 149 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 149 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 150 | 150 | $search = $productManager->createSearch(); |
| 151 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
| 152 | - $items = $productManager->searchItems( $search ); |
|
| 151 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
| 152 | + $items = $productManager->searchItems($search); |
|
| 153 | 153 | |
| 154 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 155 | - throw new \Exception( 'Product not found' ); |
|
| 154 | + if (($item = reset($items)) === false) { |
|
| 155 | + throw new \Exception('Product not found'); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' ); |
|
| 158 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product'); |
|
| 159 | 159 | $orderProductItem = $orderProductManager->createItem(); |
| 160 | - $orderProductItem->copyFrom( $item ); |
|
| 161 | - $orderProductItem->setQuantity( 2 ); |
|
| 162 | - $orderProductItem->setWarehouseCode( 'unit_warehouse3' ); |
|
| 160 | + $orderProductItem->copyFrom($item); |
|
| 161 | + $orderProductItem->setQuantity(2); |
|
| 162 | + $orderProductItem->setWarehouseCode('unit_warehouse3'); |
|
| 163 | 163 | |
| 164 | - $pos = $this->object->get()->addProduct( $orderProductItem, 1 ); |
|
| 164 | + $pos = $this->object->get()->addProduct($orderProductItem, 1); |
|
| 165 | 165 | |
| 166 | - $item = $this->object->get()->getProduct( $pos ); |
|
| 167 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
| 166 | + $item = $this->object->get()->getProduct($pos); |
|
| 167 | + $this->assertEquals(2, $item->getQuantity()); |
|
| 168 | 168 | |
| 169 | 169 | try |
| 170 | 170 | { |
| 171 | - $this->object->editProduct( $pos, 5 ); |
|
| 172 | - throw new \Exception( 'Expected exception not thrown' ); |
|
| 171 | + $this->object->editProduct($pos, 5); |
|
| 172 | + throw new \Exception('Expected exception not thrown'); |
|
| 173 | 173 | } |
| 174 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
| 174 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
| 175 | 175 | { |
| 176 | - $this->assertEquals( 3, $this->object->get()->getProduct( $pos )->getQuantity() ); |
|
| 176 | + $this->assertEquals(3, $this->object->get()->getProduct($pos)->getQuantity()); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | public function testEditProductStockNotChecked() |
| 182 | 182 | { |
| 183 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 183 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 184 | 184 | $search = $productManager->createSearch(); |
| 185 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
| 186 | - $items = $productManager->searchItems( $search ); |
|
| 185 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
| 186 | + $items = $productManager->searchItems($search); |
|
| 187 | 187 | |
| 188 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 189 | - throw new \Exception( 'Product not found' ); |
|
| 188 | + if (($item = reset($items)) === false) { |
|
| 189 | + throw new \Exception('Product not found'); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
| 192 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
| 193 | 193 | |
| 194 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 195 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
| 194 | + $item = $this->object->get()->getProduct(0); |
|
| 195 | + $this->assertEquals(2, $item->getQuantity()); |
|
| 196 | 196 | |
| 197 | - $this->object->editProduct( 0, 5, array( 'stock' => false ) ); |
|
| 197 | + $this->object->editProduct(0, 5, array('stock' => false)); |
|
| 198 | 198 | |
| 199 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 200 | - $this->assertEquals( 5, $item->getQuantity() ); |
|
| 201 | - $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
| 199 | + $item = $this->object->get()->getProduct(0); |
|
| 200 | + $this->assertEquals(5, $item->getQuantity()); |
|
| 201 | + $this->assertEquals('IJKL', $item->getProductCode()); |
|
| 202 | 202 | } |
| 203 | 203 | } |
@@ -15,63 +15,63 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | protected function setUp() |
| 17 | 17 | { |
| 18 | - $this->object = new \Aimeos\Controller\Frontend\Catalog\Standard( \TestHelperFrontend::getContext() ); |
|
| 18 | + $this->object = new \Aimeos\Controller\Frontend\Catalog\Standard(\TestHelperFrontend::getContext()); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | protected function tearDown() |
| 23 | 23 | { |
| 24 | - unset( $this->object ); |
|
| 24 | + unset($this->object); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | public function testCreateManager() |
| 29 | 29 | { |
| 30 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->createManager( 'product' ) ); |
|
| 30 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->createManager('product')); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | public function testCreateCatalogFilter() |
| 35 | 35 | { |
| 36 | - $filter = $this->object->createCatalogFilter( true ); |
|
| 36 | + $filter = $this->object->createCatalogFilter(true); |
|
| 37 | 37 | |
| 38 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 39 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Expression\\Compare\\Iface', $filter->getConditions() ); |
|
| 40 | - $this->assertEquals( 'catalog.status', $filter->getConditions()->getName() ); |
|
| 38 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 39 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Expression\\Compare\\Iface', $filter->getConditions()); |
|
| 40 | + $this->assertEquals('catalog.status', $filter->getConditions()->getName()); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | public function testGetCatalogPath() |
| 45 | 45 | { |
| 46 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 47 | - $item = $manager->getTree( null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); |
|
| 46 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 47 | + $item = $manager->getTree(null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST); |
|
| 48 | 48 | |
| 49 | 49 | $list = array(); |
| 50 | - foreach( $this->object->getCatalogPath( $item->getChild( 0 )->getId(), array( 'text' ) ) as $item ) { |
|
| 50 | + foreach ($this->object->getCatalogPath($item->getChild(0)->getId(), array('text')) as $item) { |
|
| 51 | 51 | $list[$item->getCode()] = $item; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $this->assertEquals( 2, count( $list ) ); |
|
| 55 | - $this->assertArrayHasKey( 'root', $list ); |
|
| 56 | - $this->assertArrayHasKey( 'categories', $list ); |
|
| 54 | + $this->assertEquals(2, count($list)); |
|
| 55 | + $this->assertArrayHasKey('root', $list); |
|
| 56 | + $this->assertArrayHasKey('categories', $list); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | public function testGetCatalogTree() |
| 61 | 61 | { |
| 62 | - $item = $this->object->getCatalogTree( null, array( 'text' ), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
|
| 62 | + $item = $this->object->getCatalogTree(null, array('text'), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE); |
|
| 63 | 63 | |
| 64 | - $this->assertEquals( 'Root', $item->getName() ); |
|
| 65 | - $this->assertEquals( 0, count( $item->getChildren() ) ); |
|
| 64 | + $this->assertEquals('Root', $item->getName()); |
|
| 65 | + $this->assertEquals(0, count($item->getChildren())); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | public function testAggregateIndex() |
| 70 | 70 | { |
| 71 | 71 | $filter = $this->object->createIndexFilter(); |
| 72 | - $list = $this->object->aggregateIndex( $filter, 'index.attribute.id' ); |
|
| 72 | + $list = $this->object->aggregateIndex($filter, 'index.attribute.id'); |
|
| 73 | 73 | |
| 74 | - $this->assertGreaterThan( 0, count( $list ) ); |
|
| 74 | + $this->assertGreaterThan(0, count($list)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -79,279 +79,279 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $filter = $this->object->createIndexFilter(); |
| 81 | 81 | |
| 82 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 83 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 84 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
| 85 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
| 82 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 83 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 84 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
| 85 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | public function testCreateIndexFilterCategory() |
| 90 | 90 | { |
| 91 | - $filter = $this->object->createIndexFilterCategory( 0 ); |
|
| 91 | + $filter = $this->object->createIndexFilterCategory(0); |
|
| 92 | 92 | |
| 93 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 93 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 94 | 94 | |
| 95 | 95 | $list = $filter->getConditions()->getExpressions(); |
| 96 | 96 | |
| 97 | 97 | |
| 98 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 99 | - throw new \Exception( 'Wrong expression' ); |
|
| 98 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 99 | + throw new \Exception('Wrong expression'); |
|
| 100 | 100 | } |
| 101 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
| 102 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
| 101 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
| 102 | + $this->assertEquals(0, $list[0]->getValue()); |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 106 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
| 107 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
| 105 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 106 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
| 107 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | public function testCreateIndexFilterCategoryPosition() |
| 112 | 112 | { |
| 113 | - $filter = $this->object->createIndexFilterCategory( 0, 'relevance', '-', 1, 2, 'test' ); |
|
| 113 | + $filter = $this->object->createIndexFilterCategory(0, 'relevance', '-', 1, 2, 'test'); |
|
| 114 | 114 | |
| 115 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 115 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 116 | 116 | |
| 117 | 117 | $sort = $filter->getSortations(); |
| 118 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 119 | - throw new \Exception( 'Sortation not set' ); |
|
| 118 | + if (($item = reset($sort)) === false) { |
|
| 119 | + throw new \Exception('Sortation not set'); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $this->assertEquals( 'sort:index.catalog.position("test",0)', $item->getName() ); |
|
| 123 | - $this->assertEquals( '-', $item->getOperator() ); |
|
| 122 | + $this->assertEquals('sort:index.catalog.position("test",0)', $item->getName()); |
|
| 123 | + $this->assertEquals('-', $item->getOperator()); |
|
| 124 | 124 | |
| 125 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
| 126 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
| 125 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
| 126 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
| 130 | 130 | public function testCreateIndexFilterCategoryCode() |
| 131 | 131 | { |
| 132 | - $filter = $this->object->createIndexFilterCategory( 0, 'code' ); |
|
| 132 | + $filter = $this->object->createIndexFilterCategory(0, 'code'); |
|
| 133 | 133 | |
| 134 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 134 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 135 | 135 | |
| 136 | 136 | $sort = $filter->getSortations(); |
| 137 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 138 | - throw new \Exception( 'Sortation not set' ); |
|
| 137 | + if (($item = reset($sort)) === false) { |
|
| 138 | + throw new \Exception('Sortation not set'); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $this->assertStringStartsWith( 'product.code', $item->getName() ); |
|
| 141 | + $this->assertStringStartsWith('product.code', $item->getName()); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | |
| 145 | 145 | public function testCreateIndexFilterCategoryName() |
| 146 | 146 | { |
| 147 | - $filter = $this->object->createIndexFilterCategory( 0, 'name' ); |
|
| 147 | + $filter = $this->object->createIndexFilterCategory(0, 'name'); |
|
| 148 | 148 | |
| 149 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 149 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 150 | 150 | |
| 151 | 151 | $sort = $filter->getSortations(); |
| 152 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 153 | - throw new \Exception( 'Sortation not set' ); |
|
| 152 | + if (($item = reset($sort)) === false) { |
|
| 153 | + throw new \Exception('Sortation not set'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
| 156 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | public function testCreateIndexFilterCategoryPrice() |
| 161 | 161 | { |
| 162 | - $filter = $this->object->createIndexFilterCategory( 0, 'price' ); |
|
| 162 | + $filter = $this->object->createIndexFilterCategory(0, 'price'); |
|
| 163 | 163 | |
| 164 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 164 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 165 | 165 | |
| 166 | 166 | $sort = $filter->getSortations(); |
| 167 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 168 | - throw new \Exception( 'Sortation not set' ); |
|
| 167 | + if (($item = reset($sort)) === false) { |
|
| 168 | + throw new \Exception('Sortation not set'); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
| 171 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
| 175 | 175 | public function testCreateIndexFilterCategoryInvalidSortation() |
| 176 | 176 | { |
| 177 | - $filter = $this->object->createIndexFilterCategory( 0, 'failure' ); |
|
| 177 | + $filter = $this->object->createIndexFilterCategory(0, 'failure'); |
|
| 178 | 178 | |
| 179 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 180 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 179 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 180 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | public function testAddIndexFilterCategory() |
| 185 | 185 | { |
| 186 | 186 | $filter = $this->object->createIndexFilter(); |
| 187 | - $filter = $this->object->addIndexFilterCategory( $filter, 0 ); |
|
| 187 | + $filter = $this->object->addIndexFilterCategory($filter, 0); |
|
| 188 | 188 | |
| 189 | 189 | $list = $filter->getConditions()->getExpressions(); |
| 190 | 190 | |
| 191 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 192 | - throw new \Exception( 'Wrong expression' ); |
|
| 191 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 192 | + throw new \Exception('Wrong expression'); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
| 196 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
| 197 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 195 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
| 196 | + $this->assertEquals(0, $list[0]->getValue()); |
|
| 197 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | |
| 201 | 201 | public function testCreateIndexFilterText() |
| 202 | 202 | { |
| 203 | - $filter = $this->object->createIndexFilterText( 'Espresso' ); |
|
| 203 | + $filter = $this->object->createIndexFilterText('Espresso'); |
|
| 204 | 204 | |
| 205 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 205 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 206 | 206 | |
| 207 | 207 | $list = $filter->getConditions()->getExpressions(); |
| 208 | 208 | |
| 209 | 209 | |
| 210 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 211 | - throw new \Exception( 'Wrong expression' ); |
|
| 210 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 211 | + throw new \Exception('Wrong expression'); |
|
| 212 | 212 | } |
| 213 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
| 214 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
| 213 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
| 214 | + $this->assertEquals(0, $list[0]->getValue()); |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 218 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
| 219 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
| 217 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 218 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
| 219 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | |
| 223 | 223 | public function testCreateIndexFilterTextRelevance() |
| 224 | 224 | { |
| 225 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'relevance', '-', 1, 2, 'test' ); |
|
| 225 | + $filter = $this->object->createIndexFilterText('Espresso', 'relevance', '-', 1, 2, 'test'); |
|
| 226 | 226 | |
| 227 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 228 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 229 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
| 230 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
| 227 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 228 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 229 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
| 230 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | |
| 234 | 234 | public function testCreateIndexFilterTextCode() |
| 235 | 235 | { |
| 236 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'code' ); |
|
| 236 | + $filter = $this->object->createIndexFilterText('Espresso', 'code'); |
|
| 237 | 237 | |
| 238 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 238 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 239 | 239 | |
| 240 | 240 | $sort = $filter->getSortations(); |
| 241 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 242 | - throw new \Exception( 'Sortation not set' ); |
|
| 241 | + if (($item = reset($sort)) === false) { |
|
| 242 | + throw new \Exception('Sortation not set'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - $this->assertEquals( 'product.code', $item->getName() ); |
|
| 245 | + $this->assertEquals('product.code', $item->getName()); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | public function testCreateIndexFilterTextName() |
| 250 | 250 | { |
| 251 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'name' ); |
|
| 251 | + $filter = $this->object->createIndexFilterText('Espresso', 'name'); |
|
| 252 | 252 | |
| 253 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 253 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 254 | 254 | |
| 255 | 255 | $sort = $filter->getSortations(); |
| 256 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 257 | - throw new \Exception( 'Sortation not set' ); |
|
| 256 | + if (($item = reset($sort)) === false) { |
|
| 257 | + throw new \Exception('Sortation not set'); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
| 260 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | |
| 264 | 264 | public function testCreateIndexFilterTextPrice() |
| 265 | 265 | { |
| 266 | - $filter = $this->object->createIndexFilterCategory( 'Espresso', 'price' ); |
|
| 266 | + $filter = $this->object->createIndexFilterCategory('Espresso', 'price'); |
|
| 267 | 267 | |
| 268 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 268 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 269 | 269 | |
| 270 | 270 | $sort = $filter->getSortations(); |
| 271 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 272 | - throw new \Exception( 'Sortation not set' ); |
|
| 271 | + if (($item = reset($sort)) === false) { |
|
| 272 | + throw new \Exception('Sortation not set'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
| 275 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
| 279 | 279 | public function testCreateIndexFilterTextInvalidSortation() |
| 280 | 280 | { |
| 281 | - $filter = $this->object->createIndexFilterText( '', 'failure' ); |
|
| 281 | + $filter = $this->object->createIndexFilterText('', 'failure'); |
|
| 282 | 282 | |
| 283 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 284 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 283 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 284 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | |
| 288 | 288 | public function testAddIndexFilterText() |
| 289 | 289 | { |
| 290 | - $filter = $this->object->createIndexFilterText( 'Espresso' ); |
|
| 291 | - $filter = $this->object->addIndexFilterText( $filter, 'Espresso' ); |
|
| 290 | + $filter = $this->object->createIndexFilterText('Espresso'); |
|
| 291 | + $filter = $this->object->addIndexFilterText($filter, 'Espresso'); |
|
| 292 | 292 | |
| 293 | 293 | $list = $filter->getConditions()->getExpressions(); |
| 294 | 294 | |
| 295 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 296 | - throw new \Exception( 'Wrong expression' ); |
|
| 295 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 296 | + throw new \Exception('Wrong expression'); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
| 300 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
| 301 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
| 299 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
| 300 | + $this->assertEquals(0, $list[0]->getValue()); |
|
| 301 | + $this->assertEquals(array(), $filter->getSortations()); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | public function testGetIndexItemsCategory() |
| 306 | 306 | { |
| 307 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 307 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 308 | 308 | $search = $catalogManager->createSearch(); |
| 309 | 309 | |
| 310 | - $search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) ); |
|
| 311 | - $search->setSlice( 0, 1 ); |
|
| 312 | - $items = $catalogManager->searchItems( $search ); |
|
| 310 | + $search->setConditions($search->compare('==', 'catalog.code', 'new')); |
|
| 311 | + $search->setSlice(0, 1); |
|
| 312 | + $items = $catalogManager->searchItems($search); |
|
| 313 | 313 | |
| 314 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 315 | - throw new \Exception( 'Catalog item not found' ); |
|
| 314 | + if (($item = reset($items)) === false) { |
|
| 315 | + throw new \Exception('Catalog item not found'); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | $total = 0; |
| 319 | - $filter = $this->object->createIndexFilterCategory( $item->getId(), 'position', '+', 1, 1 ); |
|
| 320 | - $results = $this->object->getIndexItems( $filter, array(), $total ); |
|
| 319 | + $filter = $this->object->createIndexFilterCategory($item->getId(), 'position', '+', 1, 1); |
|
| 320 | + $results = $this->object->getIndexItems($filter, array(), $total); |
|
| 321 | 321 | |
| 322 | - $this->assertEquals( 3, $total ); |
|
| 323 | - $this->assertEquals( 1, count( $results ) ); |
|
| 322 | + $this->assertEquals(3, $total); |
|
| 323 | + $this->assertEquals(1, count($results)); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | 327 | public function testGetIndexItemsText() |
| 328 | 328 | { |
| 329 | 329 | $total = 0; |
| 330 | - $filter = $this->object->createIndexFilterText( 'Expresso', 'relevance', '+', 0, 1, 'unittype13' ); |
|
| 331 | - $results = $this->object->getIndexItems( $filter, array(), $total ); |
|
| 330 | + $filter = $this->object->createIndexFilterText('Expresso', 'relevance', '+', 0, 1, 'unittype13'); |
|
| 331 | + $results = $this->object->getIndexItems($filter, array(), $total); |
|
| 332 | 332 | |
| 333 | - $this->assertEquals( 1, $total ); |
|
| 334 | - $this->assertEquals( 1, count( $results ) ); |
|
| 333 | + $this->assertEquals(1, $total); |
|
| 334 | + $this->assertEquals(1, count($results)); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | |
| 338 | 338 | public function testCreateTextFilter() |
| 339 | 339 | { |
| 340 | - $filter = $this->object->createTextFilter( 'Expresso', 'name', '+', 0, 1 ); |
|
| 340 | + $filter = $this->object->createTextFilter('Expresso', 'name', '+', 0, 1); |
|
| 341 | 341 | |
| 342 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 343 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions() ); |
|
| 344 | - $this->assertEquals( 3, count( $filter->getConditions()->getExpressions() ) ); |
|
| 342 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 343 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions()); |
|
| 344 | + $this->assertEquals(3, count($filter->getConditions()->getExpressions())); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
| 348 | 348 | public function testGetTextListName() |
| 349 | 349 | { |
| 350 | - $filter = $this->object->createTextFilter( 'Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name' ); |
|
| 351 | - $results = $this->object->getTextList( $filter ); |
|
| 350 | + $filter = $this->object->createTextFilter('Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name'); |
|
| 351 | + $results = $this->object->getTextList($filter); |
|
| 352 | 352 | |
| 353 | - $this->assertEquals( 1, count( $results ) ); |
|
| 354 | - $this->assertContains( 'Cafe Noire Cappuccino', $results ); |
|
| 353 | + $this->assertEquals(1, count($results)); |
|
| 354 | + $this->assertContains('Cafe Noire Cappuccino', $results); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | } |
@@ -31,32 +31,32 @@ discard block |
||
| 31 | 31 | * @param integer $quantity New product quantity |
| 32 | 32 | * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price |
| 33 | 33 | */ |
| 34 | - protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity ) |
|
| 34 | + protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity) |
|
| 35 | 35 | { |
| 36 | 36 | $context = $this->getContext(); |
| 37 | 37 | |
| 38 | - if( empty( $prices ) ) |
|
| 38 | + if (empty($prices)) |
|
| 39 | 39 | { |
| 40 | - $parentItem = $this->getDomainItem( 'product', 'product.id', $product->getProductId(), array( 'price' ) ); |
|
| 41 | - $prices = $parentItem->getRefItems( 'price', 'default' ); |
|
| 40 | + $parentItem = $this->getDomainItem('product', 'product.id', $product->getProductId(), array('price')); |
|
| 41 | + $prices = $parentItem->getRefItems('price', 'default'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 45 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 44 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 45 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
| 46 | 46 | |
| 47 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
| 47 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
| 48 | 48 | { |
| 49 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
| 49 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
| 50 | 50 | |
| 51 | - if( count( $prices ) > 0 ) |
|
| 51 | + if (count($prices) > 0) |
|
| 52 | 52 | { |
| 53 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 54 | - $price->addItem( $attrPrice ); |
|
| 53 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
| 54 | + $price->addItem($attrPrice); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // remove product rebate of original price in favor to rebates granted for the order |
| 59 | - $price->setRebate( '0.00' ); |
|
| 59 | + $price->setRebate('0.00'); |
|
| 60 | 60 | |
| 61 | 61 | return $price; |
| 62 | 62 | } |
@@ -71,34 +71,34 @@ discard block |
||
| 71 | 71 | * @param array $refIds List of IDs that must be associated to the product |
| 72 | 72 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
| 73 | 73 | */ |
| 74 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
| 74 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
| 75 | 75 | { |
| 76 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 77 | - $search = $productManager->createSearch( true ); |
|
| 76 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 77 | + $search = $productManager->createSearch(true); |
|
| 78 | 78 | |
| 79 | 79 | $expr = array( |
| 80 | - $search->compare( '==', 'product.id', $prodId ), |
|
| 80 | + $search->compare('==', 'product.id', $prodId), |
|
| 81 | 81 | $search->getConditions(), |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - if( count( $refIds ) > 0 ) |
|
| 84 | + if (count($refIds) > 0) |
|
| 85 | 85 | { |
| 86 | - foreach( $refIds as $key => $refId ) { |
|
| 86 | + foreach ($refIds as $key => $refId) { |
|
| 87 | 87 | $refIds[$key] = (string) $refId; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $param = array( $domain, $listTypeId, $refIds ); |
|
| 91 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 90 | + $param = array($domain, $listTypeId, $refIds); |
|
| 91 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 92 | 92 | |
| 93 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
| 93 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 96 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 97 | 97 | |
| 98 | - if( count( $productManager->searchItems( $search, array() ) ) === 0 ) |
|
| 98 | + if (count($productManager->searchItems($search, array())) === 0) |
|
| 99 | 99 | { |
| 100 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId ); |
|
| 101 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 100 | + $msg = sprintf('Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId); |
|
| 101 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -114,36 +114,36 @@ discard block |
||
| 114 | 114 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
| 115 | 115 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 116 | 116 | */ |
| 117 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 118 | - array $attributeIds, $type, array $attributeValues = array() ) |
|
| 117 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 118 | + array $attributeIds, $type, array $attributeValues = array()) |
|
| 119 | 119 | { |
| 120 | - if( empty( $attributeIds ) ) { |
|
| 120 | + if (empty($attributeIds)) { |
|
| 121 | 121 | return array(); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
| 125 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
| 124 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
| 125 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
| 126 | 126 | |
| 127 | 127 | $list = array(); |
| 128 | 128 | $context = $this->getContext(); |
| 129 | 129 | |
| 130 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 131 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
| 130 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 131 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
| 132 | 132 | |
| 133 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 133 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 134 | 134 | { |
| 135 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
| 135 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
| 136 | 136 | |
| 137 | - if( !empty( $prices ) ) { |
|
| 138 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
| 137 | + if (!empty($prices)) { |
|
| 138 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $item = $orderProductAttributeManager->createItem(); |
| 142 | - $item->copyFrom( $attrItem ); |
|
| 143 | - $item->setType( $type ); |
|
| 142 | + $item->copyFrom($attrItem); |
|
| 143 | + $item->setType($type); |
|
| 144 | 144 | |
| 145 | - if( isset( $attributeValues[$id] ) ) { |
|
| 146 | - $item->setValue( $attributeValues[$id] ); |
|
| 145 | + if (isset($attributeValues[$id])) { |
|
| 146 | + $item->setValue($attributeValues[$id]); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $list[] = $item; |
@@ -161,31 +161,31 @@ discard block |
||
| 161 | 161 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
| 162 | 162 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
| 163 | 163 | */ |
| 164 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
| 164 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
| 165 | 165 | { |
| 166 | - if( empty( $attributeIds ) ) { |
|
| 166 | + if (empty($attributeIds)) { |
|
| 167 | 167 | return array(); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 170 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 171 | 171 | |
| 172 | - $search = $attributeManager->createSearch( true ); |
|
| 172 | + $search = $attributeManager->createSearch(true); |
|
| 173 | 173 | $expr = array( |
| 174 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
| 174 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
| 175 | 175 | $search->getConditions(), |
| 176 | 176 | ); |
| 177 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 178 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 177 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 178 | + $search->setSlice(0, 0x7fffffff); |
|
| 179 | 179 | |
| 180 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
| 180 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
| 181 | 181 | |
| 182 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
| 182 | + if (count($attrItems) !== count($attributeIds)) |
|
| 183 | 183 | { |
| 184 | - $expected = implode( ',', $attributeIds ); |
|
| 185 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
| 186 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
| 184 | + $expected = implode(',', $attributeIds); |
|
| 185 | + $actual = implode(',', array_keys($attrItems)); |
|
| 186 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
| 187 | 187 | |
| 188 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 188 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | return $attrItems; |
@@ -198,31 +198,31 @@ discard block |
||
| 198 | 198 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
| 199 | 199 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
| 200 | 200 | */ |
| 201 | - protected function getAttributeItems( array $orderAttributes ) |
|
| 201 | + protected function getAttributeItems(array $orderAttributes) |
|
| 202 | 202 | { |
| 203 | - if( empty( $orderAttributes ) ) { |
|
| 203 | + if (empty($orderAttributes)) { |
|
| 204 | 204 | return array(); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 208 | - $search = $attributeManager->createSearch( true ); |
|
| 207 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 208 | + $search = $attributeManager->createSearch(true); |
|
| 209 | 209 | $expr = array(); |
| 210 | 210 | |
| 211 | - foreach( $orderAttributes as $item ) |
|
| 211 | + foreach ($orderAttributes as $item) |
|
| 212 | 212 | { |
| 213 | 213 | $tmp = array( |
| 214 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 215 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
| 216 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
| 217 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
| 218 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
| 214 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 215 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
| 216 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
| 217 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
| 218 | + $search->compare('>', 'attribute.type.status', 0), |
|
| 219 | 219 | $search->getConditions(), |
| 220 | 220 | ); |
| 221 | - $expr[] = $search->combine( '&&', $tmp ); |
|
| 221 | + $expr[] = $search->combine('&&', $tmp); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
| 225 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
| 224 | + $search->setConditions($search->combine('||', $expr)); |
|
| 225 | + return $attributeManager->searchItems($search, array('price')); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | |
@@ -236,23 +236,23 @@ discard block |
||
| 236 | 236 | * @return \Aimeos\MShop\Common\Item\Iface Domain item object |
| 237 | 237 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 238 | 238 | */ |
| 239 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
| 239 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
| 240 | 240 | { |
| 241 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
| 241 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
| 242 | 242 | |
| 243 | - $search = $manager->createSearch( true ); |
|
| 243 | + $search = $manager->createSearch(true); |
|
| 244 | 244 | $expr = array( |
| 245 | - $search->compare( '==', $key, $value ), |
|
| 245 | + $search->compare('==', $key, $value), |
|
| 246 | 246 | $search->getConditions(), |
| 247 | 247 | ); |
| 248 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 248 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 249 | 249 | |
| 250 | - $result = $manager->searchItems( $search, $ref ); |
|
| 250 | + $result = $manager->searchItems($search, $ref); |
|
| 251 | 251 | |
| 252 | - if( ( $item = reset( $result ) ) === false ) |
|
| 252 | + if (($item = reset($result)) === false) |
|
| 253 | 253 | { |
| 254 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
| 255 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 254 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
| 255 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | return $item; |
@@ -266,26 +266,26 @@ discard block |
||
| 266 | 266 | * @param string $code Code of the list type |
| 267 | 267 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
| 268 | 268 | */ |
| 269 | - protected function getProductListTypeItem( $domain, $code ) |
|
| 269 | + protected function getProductListTypeItem($domain, $code) |
|
| 270 | 270 | { |
| 271 | - if( !isset( $this->listTypeAttributes[$domain][$code] ) ) |
|
| 271 | + if (!isset($this->listTypeAttributes[$domain][$code])) |
|
| 272 | 272 | { |
| 273 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
| 273 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
| 274 | 274 | |
| 275 | - $listTypeSearch = $listTypeManager->createSearch( true ); |
|
| 275 | + $listTypeSearch = $listTypeManager->createSearch(true); |
|
| 276 | 276 | $expr = array( |
| 277 | - $listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ), |
|
| 278 | - $listTypeSearch->compare( '==', 'product.lists.type.code', $code ), |
|
| 277 | + $listTypeSearch->compare('==', 'product.lists.type.domain', $domain), |
|
| 278 | + $listTypeSearch->compare('==', 'product.lists.type.code', $code), |
|
| 279 | 279 | $listTypeSearch->getConditions(), |
| 280 | 280 | ); |
| 281 | - $listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) ); |
|
| 281 | + $listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr)); |
|
| 282 | 282 | |
| 283 | - $listTypeItems = $listTypeManager->searchItems( $listTypeSearch ); |
|
| 283 | + $listTypeItems = $listTypeManager->searchItems($listTypeSearch); |
|
| 284 | 284 | |
| 285 | - if( ( $listTypeItem = reset( $listTypeItems ) ) === false ) |
|
| 285 | + if (($listTypeItem = reset($listTypeItems)) === false) |
|
| 286 | 286 | { |
| 287 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
| 288 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 287 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
| 288 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $this->listTypeAttributes[$domain][$code] = $listTypeItem; |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | * @param mixed $default Default value if no value is available for the given name |
| 304 | 304 | * @return mixed Value from the array or default value |
| 305 | 305 | */ |
| 306 | - protected function getValue( array $values, $name, $default = null ) |
|
| 306 | + protected function getValue(array $values, $name, $default = null) |
|
| 307 | 307 | { |
| 308 | - if( isset( $values[$name] ) ) { |
|
| 308 | + if (isset($values[$name])) { |
|
| 309 | 309 | return $values[$name]; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -320,24 +320,24 @@ discard block |
||
| 320 | 320 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If product is not associated to at least one category |
| 321 | 321 | * @deprecated 2016.05 |
| 322 | 322 | */ |
| 323 | - protected function checkCategory( $prodid ) |
|
| 323 | + protected function checkCategory($prodid) |
|
| 324 | 324 | { |
| 325 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 325 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 326 | 326 | |
| 327 | - $search = $catalogListManager->createSearch( true ); |
|
| 327 | + $search = $catalogListManager->createSearch(true); |
|
| 328 | 328 | $expr = array( |
| 329 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
| 329 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
| 330 | 330 | $search->getConditions() |
| 331 | 331 | ); |
| 332 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 333 | - $search->setSlice( 0, 1 ); |
|
| 332 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 333 | + $search->setSlice(0, 1); |
|
| 334 | 334 | |
| 335 | - $result = $catalogListManager->searchItems( $search ); |
|
| 335 | + $result = $catalogListManager->searchItems($search); |
|
| 336 | 336 | |
| 337 | - if( reset( $result ) === false ) |
|
| 337 | + if (reset($result) === false) |
|
| 338 | 338 | { |
| 339 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
| 340 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 339 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
| 340 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
@@ -353,32 +353,32 @@ discard block |
||
| 353 | 353 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there's not enough stock available |
| 354 | 354 | * @deprecated 2016.05 |
| 355 | 355 | */ |
| 356 | - protected function addProductInStock( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 357 | - $productId, $quantity, array $options, $warehouse ) |
|
| 356 | + protected function addProductInStock(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 357 | + $productId, $quantity, array $options, $warehouse) |
|
| 358 | 358 | { |
| 359 | 359 | $stocklevel = null; |
| 360 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
| 361 | - $stocklevel = $this->getStockLevel( $productId, $warehouse ); |
|
| 360 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
| 361 | + $stocklevel = $this->getStockLevel($productId, $warehouse); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if( $stocklevel === null || $stocklevel > 0 ) |
|
| 364 | + if ($stocklevel === null || $stocklevel > 0) |
|
| 365 | 365 | { |
| 366 | - $position = $this->basket->addProduct( $orderBaseProductItem ); |
|
| 367 | - $orderBaseProductItem = clone $this->basket->getProduct( $position ); |
|
| 366 | + $position = $this->basket->addProduct($orderBaseProductItem); |
|
| 367 | + $orderBaseProductItem = clone $this->basket->getProduct($position); |
|
| 368 | 368 | $quantity = $orderBaseProductItem->getQuantity(); |
| 369 | 369 | |
| 370 | - if( $stocklevel > 0 && $stocklevel < $quantity ) |
|
| 370 | + if ($stocklevel > 0 && $stocklevel < $quantity) |
|
| 371 | 371 | { |
| 372 | - $this->basket->deleteProduct( $position ); |
|
| 373 | - $orderBaseProductItem->setQuantity( $stocklevel ); |
|
| 374 | - $this->basket->addProduct( $orderBaseProductItem, $position ); |
|
| 372 | + $this->basket->deleteProduct($position); |
|
| 373 | + $orderBaseProductItem->setQuantity($stocklevel); |
|
| 374 | + $this->basket->addProduct($orderBaseProductItem, $position); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if( $stocklevel !== null && $stocklevel < $quantity ) |
|
| 378 | + if ($stocklevel !== null && $stocklevel < $quantity) |
|
| 379 | 379 | { |
| 380 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $orderBaseProductItem->getName() ); |
|
| 381 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 380 | + $msg = sprintf('There are not enough products "%1$s" in stock', $orderBaseProductItem->getName()); |
|
| 381 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
@@ -394,26 +394,26 @@ discard block |
||
| 394 | 394 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there's not enough stock available |
| 395 | 395 | * @deprecated 2016.05 |
| 396 | 396 | */ |
| 397 | - protected function editProductInStock( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, |
|
| 398 | - \Aimeos\MShop\Product\Item\Iface $productItem, $quantity, $position, array $options ) |
|
| 397 | + protected function editProductInStock(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, |
|
| 398 | + \Aimeos\MShop\Product\Item\Iface $productItem, $quantity, $position, array $options) |
|
| 399 | 399 | { |
| 400 | 400 | $stocklevel = null; |
| 401 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
| 402 | - $stocklevel = $this->getStockLevel( $productItem->getId(), $product->getWarehouseCode() ); |
|
| 401 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
| 402 | + $stocklevel = $this->getStockLevel($productItem->getId(), $product->getWarehouseCode()); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - $product->setQuantity( ( $stocklevel !== null && $stocklevel > 0 ? min( $stocklevel, $quantity ) : $quantity ) ); |
|
| 405 | + $product->setQuantity(($stocklevel !== null && $stocklevel > 0 ? min($stocklevel, $quantity) : $quantity)); |
|
| 406 | 406 | |
| 407 | - $this->basket->deleteProduct( $position ); |
|
| 407 | + $this->basket->deleteProduct($position); |
|
| 408 | 408 | |
| 409 | - if( $stocklevel === null || $stocklevel > 0 ) { |
|
| 410 | - $this->basket->addProduct( $product, $position ); |
|
| 409 | + if ($stocklevel === null || $stocklevel > 0) { |
|
| 410 | + $this->basket->addProduct($product, $position); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if( $stocklevel !== null && $stocklevel < $quantity ) |
|
| 413 | + if ($stocklevel !== null && $stocklevel < $quantity) |
|
| 414 | 414 | { |
| 415 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $productItem->getName() ); |
|
| 416 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 415 | + $msg = sprintf('There are not enough products "%1$s" in stock', $productItem->getName()); |
|
| 416 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | |
@@ -426,35 +426,35 @@ discard block |
||
| 426 | 426 | * @return integer|null Number of available items in stock (null for unlimited stock) |
| 427 | 427 | * @deprecated 2016.04 Use basket stock decorator instead |
| 428 | 428 | */ |
| 429 | - protected function getStockLevel( $prodid, $warehouse ) |
|
| 429 | + protected function getStockLevel($prodid, $warehouse) |
|
| 430 | 430 | { |
| 431 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
| 431 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
| 432 | 432 | |
| 433 | - $search = $manager->createSearch( true ); |
|
| 433 | + $search = $manager->createSearch(true); |
|
| 434 | 434 | $expr = array( |
| 435 | - $search->compare( '==', 'product.stock.parentid', $prodid ), |
|
| 435 | + $search->compare('==', 'product.stock.parentid', $prodid), |
|
| 436 | 436 | $search->getConditions(), |
| 437 | - $search->compare( '==', 'product.stock.warehouse.code', $warehouse ), |
|
| 437 | + $search->compare('==', 'product.stock.warehouse.code', $warehouse), |
|
| 438 | 438 | ); |
| 439 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 439 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 440 | 440 | |
| 441 | - $result = $manager->searchItems( $search ); |
|
| 441 | + $result = $manager->searchItems($search); |
|
| 442 | 442 | |
| 443 | - if( empty( $result ) ) |
|
| 443 | + if (empty($result)) |
|
| 444 | 444 | { |
| 445 | - $msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse ); |
|
| 446 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 445 | + $msg = sprintf('No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse); |
|
| 446 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | $stocklevel = null; |
| 450 | 450 | |
| 451 | - foreach( $result as $item ) |
|
| 451 | + foreach ($result as $item) |
|
| 452 | 452 | { |
| 453 | - if( ( $stock = $item->getStockLevel() ) === null ) { |
|
| 453 | + if (($stock = $item->getStockLevel()) === null) { |
|
| 454 | 454 | return null; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $stocklevel = max( (int) $stocklevel, $item->getStockLevel() ); |
|
| 457 | + $stocklevel = max((int) $stocklevel, $item->getStockLevel()); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return $stocklevel; |
@@ -41,29 +41,29 @@ discard block |
||
| 41 | 41 | * @param string $warehouse Unique code of the warehouse to deliver the products from |
| 42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 43 | 43 | */ |
| 44 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantIds = array(), |
|
| 45 | - array $configIds = array(), array $hiddenIds = array(), array $customValues = array(), $warehouse = 'default' ) |
|
| 44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantIds = array(), |
|
| 45 | + array $configIds = array(), array $hiddenIds = array(), array $customValues = array(), $warehouse = 'default') |
|
| 46 | 46 | { |
| 47 | 47 | $stocklevel = null; |
| 48 | 48 | |
| 49 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
| 50 | - $stocklevel = $this->getStockLevel( $prodid, $warehouse ); |
|
| 49 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
| 50 | + $stocklevel = $this->getStockLevel($prodid, $warehouse); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $qty = ( $stocklevel !== null ? min( $stocklevel, $quantity ) : $quantity ); |
|
| 53 | + $qty = ($stocklevel !== null ? min($stocklevel, $quantity) : $quantity); |
|
| 54 | 54 | |
| 55 | - if( $qty > 0 ) |
|
| 55 | + if ($qty > 0) |
|
| 56 | 56 | { |
| 57 | 57 | $this->getController()->addProduct( |
| 58 | 58 | $prodid, $qty, $options, $variantIds, $configIds, $hiddenIds, $customValues, $warehouse |
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if( $qty < $quantity ) |
|
| 62 | + if ($qty < $quantity) |
|
| 63 | 63 | { |
| 64 | - $product = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' )->getItem( $prodid ); |
|
| 65 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $product->getName() ); |
|
| 66 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 64 | + $product = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product')->getItem($prodid); |
|
| 65 | + $msg = sprintf('There are not enough products "%1$s" in stock', $product->getName()); |
|
| 66 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -77,23 +77,23 @@ discard block |
||
| 77 | 77 | * The 'stock'=>false option allows adding products without being in stock. |
| 78 | 78 | * @param string[] $configCodes Codes of the product config attributes that should be REMOVED |
| 79 | 79 | */ |
| 80 | - public function editProduct( $position, $quantity, array $options = array(), array $configCodes = array() ) |
|
| 80 | + public function editProduct($position, $quantity, array $options = array(), array $configCodes = array()) |
|
| 81 | 81 | { |
| 82 | 82 | $stocklevel = null; |
| 83 | - $product = $this->getController()->get()->getProduct( $position ); |
|
| 83 | + $product = $this->getController()->get()->getProduct($position); |
|
| 84 | 84 | |
| 85 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
| 86 | - $stocklevel = $this->getStockLevel( $product->getProductId(), $product->getWarehouseCode() ); |
|
| 85 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
| 86 | + $stocklevel = $this->getStockLevel($product->getProductId(), $product->getWarehouseCode()); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $qty = ( $stocklevel !== null ? min( $stocklevel, $quantity ) : $quantity ); |
|
| 89 | + $qty = ($stocklevel !== null ? min($stocklevel, $quantity) : $quantity); |
|
| 90 | 90 | |
| 91 | - $this->getController()->editProduct( $position, $qty, $options, $configCodes ); |
|
| 91 | + $this->getController()->editProduct($position, $qty, $options, $configCodes); |
|
| 92 | 92 | |
| 93 | - if( $qty < $quantity ) |
|
| 93 | + if ($qty < $quantity) |
|
| 94 | 94 | { |
| 95 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $product->getName() ); |
|
| 96 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 95 | + $msg = sprintf('There are not enough products "%1$s" in stock', $product->getName()); |
|
| 96 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
@@ -105,35 +105,35 @@ discard block |
||
| 105 | 105 | * @param string $warehouse Unique code of the warehouse |
| 106 | 106 | * @return integer|null Number of available items in stock (null for unlimited stock) |
| 107 | 107 | */ |
| 108 | - protected function getStockLevel( $prodid, $warehouse ) |
|
| 108 | + protected function getStockLevel($prodid, $warehouse) |
|
| 109 | 109 | { |
| 110 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
| 110 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
| 111 | 111 | |
| 112 | - $search = $manager->createSearch( true ); |
|
| 112 | + $search = $manager->createSearch(true); |
|
| 113 | 113 | $expr = array( |
| 114 | - $search->compare( '==', 'product.stock.parentid', $prodid ), |
|
| 114 | + $search->compare('==', 'product.stock.parentid', $prodid), |
|
| 115 | 115 | $search->getConditions(), |
| 116 | - $search->compare( '==', 'product.stock.warehouse.code', $warehouse ), |
|
| 116 | + $search->compare('==', 'product.stock.warehouse.code', $warehouse), |
|
| 117 | 117 | ); |
| 118 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 118 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 119 | 119 | |
| 120 | - $result = $manager->searchItems( $search ); |
|
| 120 | + $result = $manager->searchItems($search); |
|
| 121 | 121 | |
| 122 | - if( empty( $result ) ) |
|
| 122 | + if (empty($result)) |
|
| 123 | 123 | { |
| 124 | - $msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse ); |
|
| 125 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 124 | + $msg = sprintf('No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse); |
|
| 125 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | $stocklevel = null; |
| 129 | 129 | |
| 130 | - foreach( $result as $item ) |
|
| 130 | + foreach ($result as $item) |
|
| 131 | 131 | { |
| 132 | - if( ( $stock = $item->getStockLevel() ) === null ) { |
|
| 132 | + if (($stock = $item->getStockLevel()) === null) { |
|
| 133 | 133 | return null; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $stocklevel = max( (int) $stocklevel, $item->getStockLevel() ); |
|
| 136 | + $stocklevel = max((int) $stocklevel, $item->getStockLevel()); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return $stocklevel; |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | * @return mixed Returns the value of the called method |
| 28 | 28 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
| 29 | 29 | */ |
| 30 | - public function __call( $name, array $param ) |
|
| 30 | + public function __call($name, array $param) |
|
| 31 | 31 | { |
| 32 | - if( ( $result = call_user_func_array( array( $this->getController(), $name ), $param ) ) === false ) |
|
| 32 | + if (($result = call_user_func_array(array($this->getController(), $name), $param)) === false) |
|
| 33 | 33 | { |
| 34 | - $cntl = get_class( $this->getController() ); |
|
| 35 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Unable to call method "%1$s::%2$s"', $cntl, $name ) ); |
|
| 34 | + $cntl = get_class($this->getController()); |
|
| 35 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Unable to call method "%1$s::%2$s"', $cntl, $name)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return $result; |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 84 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 85 | 85 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
| 86 | - $warehouse = 'default' ) |
|
| 86 | + $warehouse = 'default') |
|
| 87 | 87 | { |
| 88 | 88 | $this->getController()->addProduct( |
| 89 | 89 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | * @param integer $position Position number (key) of the order product item |
| 99 | 99 | * @return void |
| 100 | 100 | */ |
| 101 | - public function deleteProduct( $position ) |
|
| 101 | + public function deleteProduct($position) |
|
| 102 | 102 | { |
| 103 | - $this->getController()->deleteProduct( $position ); |
|
| 103 | + $this->getController()->deleteProduct($position); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 113 | 113 | * @return void |
| 114 | 114 | */ |
| 115 | - public function editProduct( $position, $quantity, array $configAttributeCodes = array() ) |
|
| 115 | + public function editProduct($position, $quantity, array $configAttributeCodes = array()) |
|
| 116 | 116 | { |
| 117 | - $this->getController()->editProduct( $position, $quantity, $configAttributeCodes ); |
|
| 117 | + $this->getController()->editProduct($position, $quantity, $configAttributeCodes); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | - public function addCoupon( $code ) |
|
| 128 | + public function addCoupon($code) |
|
| 129 | 129 | { |
| 130 | - $this->getController()->addCoupon( $code ); |
|
| 130 | + $this->getController()->addCoupon($code); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 139 | 139 | * @return void |
| 140 | 140 | */ |
| 141 | - public function deleteCoupon( $code ) |
|
| 141 | + public function deleteCoupon($code) |
|
| 142 | 142 | { |
| 143 | - $this->getController()->deleteCoupon( $code ); |
|
| 143 | + $this->getController()->deleteCoupon($code); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | * if one of the keys is invalid when using an array with key/value pairs |
| 154 | 154 | * @return void |
| 155 | 155 | */ |
| 156 | - public function setAddress( $type, $value ) |
|
| 156 | + public function setAddress($type, $value) |
|
| 157 | 157 | { |
| 158 | - $this->getController()->setAddress( $type, $value ); |
|
| 158 | + $this->getController()->setAddress($type, $value); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 170 | 170 | * @return void |
| 171 | 171 | */ |
| 172 | - public function setService( $type, $id, array $attributes = array() ) |
|
| 172 | + public function setService($type, $id, array $attributes = array()) |
|
| 173 | 173 | { |
| 174 | - $this->getController()->setService( $type, $id, $attributes ); |
|
| 174 | + $this->getController()->setService($type, $id, $attributes); |
|
| 175 | 175 | } |
| 176 | 176 | } |