@@ -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 |
@@ -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 | } |
@@ -160,8 +160,7 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $this->setAddress( $type, $item->toArray() ); |
| 162 | 162 | $basket->deleteAddress( $type ); |
| 163 | - } |
|
| 164 | - catch( \Exception $e ) |
|
| 163 | + } catch( \Exception $e ) |
|
| 165 | 164 | { |
| 166 | 165 | $logger = $this->getContext()->getLogger(); |
| 167 | 166 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -190,8 +189,7 @@ discard block |
||
| 190 | 189 | { |
| 191 | 190 | $this->addCoupon( $code ); |
| 192 | 191 | $basket->deleteCoupon( $code, true ); |
| 193 | - } |
|
| 194 | - catch( \Exception $e ) |
|
| 192 | + } catch( \Exception $e ) |
|
| 195 | 193 | { |
| 196 | 194 | $logger = $this->getContext()->getLogger(); |
| 197 | 195 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -240,8 +238,7 @@ discard block |
||
| 240 | 238 | ); |
| 241 | 239 | |
| 242 | 240 | $basket->deleteProduct( $pos ); |
| 243 | - } |
|
| 244 | - catch( \Exception $e ) |
|
| 241 | + } catch( \Exception $e ) |
|
| 245 | 242 | { |
| 246 | 243 | $code = $product->getProductCode(); |
| 247 | 244 | $logger = $this->getContext()->getLogger(); |
@@ -276,8 +273,7 @@ discard block |
||
| 276 | 273 | |
| 277 | 274 | $this->setService( $type, $item->getServiceId(), $attributes ); |
| 278 | 275 | $basket->deleteService( $type ); |
| 279 | - } |
|
| 280 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 276 | + } catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 281 | 277 | } |
| 282 | 278 | |
| 283 | 279 | return $errors; |
@@ -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 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 41 | - $prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' ); |
|
| 40 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 41 | + $prices = $manager->getItem($product->getProductId(), array('price'))->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 | |
@@ -113,34 +113,34 @@ discard block |
||
| 113 | 113 | $session = $context->getSession(); |
| 114 | 114 | $locale = $this->get()->getLocale(); |
| 115 | 115 | |
| 116 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
| 116 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
| 117 | 117 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
| 118 | 118 | |
| 119 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
| 119 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
| 120 | 120 | { |
| 121 | - $locParts = explode( '|', $localeStr ); |
|
| 122 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
| 123 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
| 124 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
| 121 | + $locParts = explode('|', $localeStr); |
|
| 122 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
| 123 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
| 124 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
| 125 | 125 | |
| 126 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 127 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
| 126 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
| 127 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
| 128 | 128 | |
| 129 | 129 | $context = clone $context; |
| 130 | - $context->setLocale( $locale ); |
|
| 130 | + $context->setLocale($locale); |
|
| 131 | 131 | |
| 132 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
| 132 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
| 133 | 133 | $basket = $manager->getSession(); |
| 134 | 134 | |
| 135 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
| 136 | - $this->copyServices( $basket, $errors ); |
|
| 137 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
| 138 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
| 135 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
| 136 | + $this->copyServices($basket, $errors); |
|
| 137 | + $this->copyProducts($basket, $errors, $localeKey); |
|
| 138 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
| 139 | 139 | |
| 140 | - $manager->setSession( $basket ); |
|
| 140 | + $manager->setSession($basket); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
| 143 | + $session->set('aimeos/basket/locale', $localeKey); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -152,20 +152,20 @@ discard block |
||
| 152 | 152 | * @param string $localeKey Unique identifier of the site, language and currency |
| 153 | 153 | * @return array Associative list of errors occured |
| 154 | 154 | */ |
| 155 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 155 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 156 | 156 | { |
| 157 | - foreach( $basket->getAddresses() as $type => $item ) |
|
| 157 | + foreach ($basket->getAddresses() as $type => $item) |
|
| 158 | 158 | { |
| 159 | 159 | try |
| 160 | 160 | { |
| 161 | - $this->setAddress( $type, $item->toArray() ); |
|
| 162 | - $basket->deleteAddress( $type ); |
|
| 161 | + $this->setAddress($type, $item->toArray()); |
|
| 162 | + $basket->deleteAddress($type); |
|
| 163 | 163 | } |
| 164 | - catch( \Exception $e ) |
|
| 164 | + catch (\Exception $e) |
|
| 165 | 165 | { |
| 166 | 166 | $logger = $this->getContext()->getLogger(); |
| 167 | 167 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
| 168 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 168 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 169 | 169 | $errors['address'][$type] = $e->getMessage(); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -182,20 +182,20 @@ discard block |
||
| 182 | 182 | * @param string $localeKey Unique identifier of the site, language and currency |
| 183 | 183 | * @return array Associative list of errors occured |
| 184 | 184 | */ |
| 185 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 185 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 186 | 186 | { |
| 187 | - foreach( $basket->getCoupons() as $code => $list ) |
|
| 187 | + foreach ($basket->getCoupons() as $code => $list) |
|
| 188 | 188 | { |
| 189 | 189 | try |
| 190 | 190 | { |
| 191 | - $this->addCoupon( $code ); |
|
| 192 | - $basket->deleteCoupon( $code, true ); |
|
| 191 | + $this->addCoupon($code); |
|
| 192 | + $basket->deleteCoupon($code, true); |
|
| 193 | 193 | } |
| 194 | - catch( \Exception $e ) |
|
| 194 | + catch (\Exception $e) |
|
| 195 | 195 | { |
| 196 | 196 | $logger = $this->getContext()->getLogger(); |
| 197 | 197 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 198 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 198 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 199 | 199 | $errors['coupon'][$code] = $e->getMessage(); |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | * @param string $localeKey Unique identifier of the site, language and currency |
| 213 | 213 | * @return array Associative list of errors occured |
| 214 | 214 | */ |
| 215 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 215 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 216 | 216 | { |
| 217 | - foreach( $basket->getProducts() as $pos => $product ) |
|
| 217 | + foreach ($basket->getProducts() as $pos => $product) |
|
| 218 | 218 | { |
| 219 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
| 219 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
| 220 | 220 | continue; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | $attrIds = array(); |
| 226 | 226 | |
| 227 | - foreach( $product->getAttributes() as $attrItem ) { |
|
| 227 | + foreach ($product->getAttributes() as $attrItem) { |
|
| 228 | 228 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
| 229 | 229 | } |
| 230 | 230 | |
@@ -232,21 +232,21 @@ discard block |
||
| 232 | 232 | $product->getProductId(), |
| 233 | 233 | $product->getQuantity(), |
| 234 | 234 | array(), |
| 235 | - $this->getValue( $attrIds, 'variant', array() ), |
|
| 236 | - $this->getValue( $attrIds, 'config', array() ), |
|
| 237 | - $this->getValue( $attrIds, 'hidden', array() ), |
|
| 238 | - $this->getValue( $attrIds, 'custom', array() ), |
|
| 235 | + $this->getValue($attrIds, 'variant', array()), |
|
| 236 | + $this->getValue($attrIds, 'config', array()), |
|
| 237 | + $this->getValue($attrIds, 'hidden', array()), |
|
| 238 | + $this->getValue($attrIds, 'custom', array()), |
|
| 239 | 239 | $product->getStockType() |
| 240 | 240 | ); |
| 241 | 241 | |
| 242 | - $basket->deleteProduct( $pos ); |
|
| 242 | + $basket->deleteProduct($pos); |
|
| 243 | 243 | } |
| 244 | - catch( \Exception $e ) |
|
| 244 | + catch (\Exception $e) |
|
| 245 | 245 | { |
| 246 | 246 | $code = $product->getProductCode(); |
| 247 | 247 | $logger = $this->getContext()->getLogger(); |
| 248 | 248 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 249 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 249 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 250 | 250 | $errors['product'][$pos] = $e->getMessage(); |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -262,22 +262,22 @@ discard block |
||
| 262 | 262 | * @param array $errors Associative list of previous errors |
| 263 | 263 | * @return array Associative list of errors occured |
| 264 | 264 | */ |
| 265 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
| 265 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
| 266 | 266 | { |
| 267 | - foreach( $basket->getServices() as $type => $item ) |
|
| 267 | + foreach ($basket->getServices() as $type => $item) |
|
| 268 | 268 | { |
| 269 | 269 | try |
| 270 | 270 | { |
| 271 | 271 | $attributes = array(); |
| 272 | 272 | |
| 273 | - foreach( $item->getAttributes() as $attrItem ) { |
|
| 273 | + foreach ($item->getAttributes() as $attrItem) { |
|
| 274 | 274 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
| 278 | - $basket->deleteService( $type ); |
|
| 277 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
| 278 | + $basket->deleteService($type); |
|
| 279 | 279 | } |
| 280 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 280 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | return $errors; |
@@ -295,36 +295,36 @@ discard block |
||
| 295 | 295 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
| 296 | 296 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 297 | 297 | */ |
| 298 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 299 | - array $attributeIds, $type, array $attributeValues = array() ) |
|
| 298 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 299 | + array $attributeIds, $type, array $attributeValues = array()) |
|
| 300 | 300 | { |
| 301 | - if( empty( $attributeIds ) ) { |
|
| 301 | + if (empty($attributeIds)) { |
|
| 302 | 302 | return array(); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
| 306 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
| 305 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
| 306 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
| 307 | 307 | |
| 308 | 308 | $list = array(); |
| 309 | 309 | $context = $this->getContext(); |
| 310 | 310 | |
| 311 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 312 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
| 311 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 312 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
| 313 | 313 | |
| 314 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 314 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 315 | 315 | { |
| 316 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
| 316 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
| 317 | 317 | |
| 318 | - if( !empty( $prices ) ) { |
|
| 319 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
| 318 | + if (!empty($prices)) { |
|
| 319 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | $item = $orderProductAttributeManager->createItem(); |
| 323 | - $item->copyFrom( $attrItem ); |
|
| 324 | - $item->setType( $type ); |
|
| 323 | + $item->copyFrom($attrItem); |
|
| 324 | + $item->setType($type); |
|
| 325 | 325 | |
| 326 | - if( isset( $attributeValues[$id] ) ) { |
|
| 327 | - $item->setValue( $attributeValues[$id] ); |
|
| 326 | + if (isset($attributeValues[$id])) { |
|
| 327 | + $item->setValue($attributeValues[$id]); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $list[] = $item; |
@@ -342,31 +342,31 @@ discard block |
||
| 342 | 342 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
| 343 | 343 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
| 344 | 344 | */ |
| 345 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
| 345 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
| 346 | 346 | { |
| 347 | - if( empty( $attributeIds ) ) { |
|
| 347 | + if (empty($attributeIds)) { |
|
| 348 | 348 | return array(); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 351 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 352 | 352 | |
| 353 | - $search = $attributeManager->createSearch( true ); |
|
| 353 | + $search = $attributeManager->createSearch(true); |
|
| 354 | 354 | $expr = array( |
| 355 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
| 355 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
| 356 | 356 | $search->getConditions(), |
| 357 | 357 | ); |
| 358 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 359 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 358 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 359 | + $search->setSlice(0, 0x7fffffff); |
|
| 360 | 360 | |
| 361 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
| 361 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
| 362 | 362 | |
| 363 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
| 363 | + if (count($attrItems) !== count($attributeIds)) |
|
| 364 | 364 | { |
| 365 | - $expected = implode( ',', $attributeIds ); |
|
| 366 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
| 367 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
| 365 | + $expected = implode(',', $attributeIds); |
|
| 366 | + $actual = implode(',', array_keys($attrItems)); |
|
| 367 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
| 368 | 368 | |
| 369 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 369 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | return $attrItems; |
@@ -379,31 +379,31 @@ discard block |
||
| 379 | 379 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
| 380 | 380 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
| 381 | 381 | */ |
| 382 | - protected function getAttributeItems( array $orderAttributes ) |
|
| 382 | + protected function getAttributeItems(array $orderAttributes) |
|
| 383 | 383 | { |
| 384 | - if( empty( $orderAttributes ) ) { |
|
| 384 | + if (empty($orderAttributes)) { |
|
| 385 | 385 | return array(); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 389 | - $search = $attributeManager->createSearch( true ); |
|
| 388 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 389 | + $search = $attributeManager->createSearch(true); |
|
| 390 | 390 | $expr = array(); |
| 391 | 391 | |
| 392 | - foreach( $orderAttributes as $item ) |
|
| 392 | + foreach ($orderAttributes as $item) |
|
| 393 | 393 | { |
| 394 | 394 | $tmp = array( |
| 395 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 396 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
| 397 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
| 398 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
| 399 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
| 395 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 396 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
| 397 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
| 398 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
| 399 | + $search->compare('>', 'attribute.type.status', 0), |
|
| 400 | 400 | $search->getConditions(), |
| 401 | 401 | ); |
| 402 | - $expr[] = $search->combine( '&&', $tmp ); |
|
| 402 | + $expr[] = $search->combine('&&', $tmp); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
| 406 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
| 405 | + $search->setConditions($search->combine('||', $expr)); |
|
| 406 | + return $attributeManager->searchItems($search, array('price')); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | |
@@ -417,23 +417,23 @@ discard block |
||
| 417 | 417 | * @return \Aimeos\MShop\Common\Item\Iface Domain item object |
| 418 | 418 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 419 | 419 | */ |
| 420 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
| 420 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
| 421 | 421 | { |
| 422 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
| 422 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
| 423 | 423 | |
| 424 | - $search = $manager->createSearch( true ); |
|
| 424 | + $search = $manager->createSearch(true); |
|
| 425 | 425 | $expr = array( |
| 426 | - $search->compare( '==', $key, $value ), |
|
| 426 | + $search->compare('==', $key, $value), |
|
| 427 | 427 | $search->getConditions(), |
| 428 | 428 | ); |
| 429 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 429 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 430 | 430 | |
| 431 | - $result = $manager->searchItems( $search, $ref ); |
|
| 431 | + $result = $manager->searchItems($search, $ref); |
|
| 432 | 432 | |
| 433 | - if( ( $item = reset( $result ) ) === false ) |
|
| 433 | + if (($item = reset($result)) === false) |
|
| 434 | 434 | { |
| 435 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
| 436 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 435 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
| 436 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | return $item; |
@@ -447,26 +447,26 @@ discard block |
||
| 447 | 447 | * @param string $code Code of the list type |
| 448 | 448 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
| 449 | 449 | */ |
| 450 | - protected function getProductListTypeItem( $domain, $code ) |
|
| 450 | + protected function getProductListTypeItem($domain, $code) |
|
| 451 | 451 | { |
| 452 | - if( !isset( $this->listTypeAttributes[$domain][$code] ) ) |
|
| 452 | + if (!isset($this->listTypeAttributes[$domain][$code])) |
|
| 453 | 453 | { |
| 454 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
| 454 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
| 455 | 455 | |
| 456 | - $listTypeSearch = $listTypeManager->createSearch( true ); |
|
| 456 | + $listTypeSearch = $listTypeManager->createSearch(true); |
|
| 457 | 457 | $expr = array( |
| 458 | - $listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ), |
|
| 459 | - $listTypeSearch->compare( '==', 'product.lists.type.code', $code ), |
|
| 458 | + $listTypeSearch->compare('==', 'product.lists.type.domain', $domain), |
|
| 459 | + $listTypeSearch->compare('==', 'product.lists.type.code', $code), |
|
| 460 | 460 | $listTypeSearch->getConditions(), |
| 461 | 461 | ); |
| 462 | - $listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) ); |
|
| 462 | + $listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr)); |
|
| 463 | 463 | |
| 464 | - $listTypeItems = $listTypeManager->searchItems( $listTypeSearch ); |
|
| 464 | + $listTypeItems = $listTypeManager->searchItems($listTypeSearch); |
|
| 465 | 465 | |
| 466 | - if( ( $listTypeItem = reset( $listTypeItems ) ) === false ) |
|
| 466 | + if (($listTypeItem = reset($listTypeItems)) === false) |
|
| 467 | 467 | { |
| 468 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
| 469 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 468 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
| 469 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | $this->listTypeAttributes[$domain][$code] = $listTypeItem; |
@@ -484,43 +484,43 @@ discard block |
||
| 484 | 484 | * @param array $domains Names of the domain items that should be fetched too |
| 485 | 485 | * @return array List of products matching the given attributes |
| 486 | 486 | */ |
| 487 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 488 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
| 487 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 488 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
| 489 | 489 | { |
| 490 | 490 | $subProductIds = array(); |
| 491 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
| 491 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
| 492 | 492 | $subProductIds[] = $item->getId(); |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - if( count( $subProductIds ) === 0 ) { |
|
| 495 | + if (count($subProductIds) === 0) { |
|
| 496 | 496 | return array(); |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 500 | - $search = $productManager->createSearch( true ); |
|
| 499 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 500 | + $search = $productManager->createSearch(true); |
|
| 501 | 501 | |
| 502 | 502 | $expr = array( |
| 503 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 503 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 504 | 504 | $search->getConditions(), |
| 505 | 505 | ); |
| 506 | 506 | |
| 507 | - if( count( $variantAttributeIds ) > 0 ) |
|
| 507 | + if (count($variantAttributeIds) > 0) |
|
| 508 | 508 | { |
| 509 | - foreach( $variantAttributeIds as $key => $id ) { |
|
| 509 | + foreach ($variantAttributeIds as $key => $id) { |
|
| 510 | 510 | $variantAttributeIds[$key] = (string) $id; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
| 513 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
| 514 | 514 | |
| 515 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
| 516 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 515 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
| 516 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 517 | 517 | |
| 518 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
| 518 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 521 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 522 | 522 | |
| 523 | - return $productManager->searchItems( $search, $domains ); |
|
| 523 | + return $productManager->searchItems($search, $domains); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | |
@@ -532,9 +532,9 @@ discard block |
||
| 532 | 532 | * @param mixed $default Default value if no value is available for the given name |
| 533 | 533 | * @return mixed Value from the array or default value |
| 534 | 534 | */ |
| 535 | - protected function getValue( array $values, $name, $default = null ) |
|
| 535 | + protected function getValue(array $values, $name, $default = null) |
|
| 536 | 536 | { |
| 537 | - if( isset( $values[$name] ) ) { |
|
| 537 | + if (isset($values[$name])) { |
|
| 538 | 538 | return $values[$name]; |
| 539 | 539 | } |
| 540 | 540 | |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | 'frontend' => array( |
| 5 | 5 | 'basket' => array( |
| 6 | 6 | 'decorators' => array( |
| 7 | - 'local' => array( 'Category' ), |
|
| 7 | + 'local' => array('Category'), |
|
| 8 | 8 | ), |
| 9 | 9 | ), |
| 10 | 10 | ), |
@@ -15,15 +15,15 @@ discard block |
||
| 15 | 15 | public static function bootstrap() |
| 16 | 16 | { |
| 17 | 17 | self::getAimeos(); |
| 18 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 19 | - \Aimeos\Controller\Frontend\Factory::setCache( false ); |
|
| 18 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 19 | + \Aimeos\Controller\Frontend\Factory::setCache(false); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
| 23 | - public static function getContext( $site = 'unittest' ) |
|
| 23 | + public static function getContext($site = 'unittest') |
|
| 24 | 24 | { |
| 25 | - if( !isset( self::$context[$site] ) ) { |
|
| 26 | - self::$context[$site] = self::createContext( $site ); |
|
| 25 | + if (!isset(self::$context[$site])) { |
|
| 26 | + self::$context[$site] = self::createContext($site); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return clone self::$context[$site]; |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | private static function getAimeos() |
| 34 | 34 | { |
| 35 | - if( !isset( self::$aimeos ) ) |
|
| 35 | + if (!isset(self::$aimeos)) |
|
| 36 | 36 | { |
| 37 | 37 | require_once 'Bootstrap.php'; |
| 38 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
| 38 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
| 39 | 39 | |
| 40 | - $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
|
| 41 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
| 40 | + $extdir = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
| 41 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | return self::$aimeos; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * @param string $site |
| 50 | 50 | */ |
| 51 | - private static function createContext( $site ) |
|
| 51 | + private static function createContext($site) |
|
| 52 | 52 | { |
| 53 | 53 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
| 54 | 54 | $aimeos = self::getAimeos(); |
@@ -58,34 +58,34 @@ discard block |
||
| 58 | 58 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
| 59 | 59 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
| 60 | 60 | |
| 61 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $paths ); |
|
| 62 | - $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
|
| 63 | - $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
|
| 64 | - $ctx->setConfig( $conf ); |
|
| 61 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); |
|
| 62 | + $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); |
|
| 63 | + $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); |
|
| 64 | + $ctx->setConfig($conf); |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
| 68 | - $ctx->setDatabaseManager( $dbm ); |
|
| 67 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
| 68 | + $ctx->setDatabaseManager($dbm); |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - $logger = new \Aimeos\MW\Logger\File( 'unittest.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
| 72 | - $ctx->setLogger( $logger ); |
|
| 71 | + $logger = new \Aimeos\MW\Logger\File('unittest.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
| 72 | + $ctx->setLogger($logger); |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
| 76 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
| 75 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
| 76 | + $ctx->setI18n(array('de' => $i18n)); |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | $session = new \Aimeos\MW\Session\None(); |
| 80 | - $ctx->setSession( $session ); |
|
| 80 | + $ctx->setSession($session); |
|
| 81 | 81 | |
| 82 | 82 | |
| 83 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
| 84 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
| 85 | - $ctx->setLocale( $locale ); |
|
| 83 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
| 84 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
| 85 | + $ctx->setLocale($locale); |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - $ctx->setEditor( 'core:controller/frontend' ); |
|
| 88 | + $ctx->setEditor('core:controller/frontend'); |
|
| 89 | 89 | |
| 90 | 90 | return $ctx; |
| 91 | 91 | } |
@@ -16,130 +16,130 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | protected function setUp() |
| 18 | 18 | { |
| 19 | - $this->object = new \Aimeos\Controller\Frontend\Service\Standard( \TestHelperFrontend::getContext() ); |
|
| 19 | + $this->object = new \Aimeos\Controller\Frontend\Service\Standard(\TestHelperFrontend::getContext()); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | public static function setUpBeforeClass() |
| 24 | 24 | { |
| 25 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 26 | - $orderBaseMgr = $orderManager->getSubManager( 'base' ); |
|
| 25 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 26 | + $orderBaseMgr = $orderManager->getSubManager('base'); |
|
| 27 | 27 | self::$basket = $orderBaseMgr->createItem(); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | protected function tearDown() |
| 32 | 32 | { |
| 33 | - unset( $this->object ); |
|
| 33 | + unset($this->object); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | public function testGetServices() |
| 38 | 38 | { |
| 39 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 40 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
| 39 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 40 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
| 41 | 41 | |
| 42 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
| 43 | - $this->assertGreaterThan( 0, count( $services ) ); |
|
| 42 | + $services = $this->object->getServices('delivery', $basket); |
|
| 43 | + $this->assertGreaterThan(0, count($services)); |
|
| 44 | 44 | |
| 45 | - foreach( $services as $service ) { |
|
| 46 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Item\\Iface', $service ); |
|
| 45 | + foreach ($services as $service) { |
|
| 46 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Item\\Iface', $service); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function testGetServicesCache() |
| 52 | 52 | { |
| 53 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 54 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
| 53 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 54 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
| 55 | 55 | |
| 56 | - $this->object->getServices( 'delivery', $basket ); |
|
| 57 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
| 56 | + $this->object->getServices('delivery', $basket); |
|
| 57 | + $services = $this->object->getServices('delivery', $basket); |
|
| 58 | 58 | |
| 59 | - $this->assertGreaterThan( 0, count( $services ) ); |
|
| 59 | + $this->assertGreaterThan(0, count($services)); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | public function testGetServiceAttributes() |
| 64 | 64 | { |
| 65 | 65 | $service = $this->getServiceItem(); |
| 66 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
| 66 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
| 67 | 67 | |
| 68 | - $this->assertEquals( 0, count( $attributes ) ); |
|
| 68 | + $this->assertEquals(0, count($attributes)); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | public function testGetServiceAttributesCache() |
| 73 | 73 | { |
| 74 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 75 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
| 74 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 75 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
| 76 | 76 | |
| 77 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
| 77 | + $services = $this->object->getServices('delivery', $basket); |
|
| 78 | 78 | |
| 79 | - if( ( $service = reset( $services ) ) === false ) { |
|
| 80 | - throw new \RuntimeException( 'No service item found' ); |
|
| 79 | + if (($service = reset($services)) === false) { |
|
| 80 | + throw new \RuntimeException('No service item found'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
| 83 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
| 84 | 84 | |
| 85 | - $this->assertEquals( 0, count( $attributes ) ); |
|
| 85 | + $this->assertEquals(0, count($attributes)); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | public function testGetServiceAttributesNoItems() |
| 90 | 90 | { |
| 91 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Service\\Exception' ); |
|
| 92 | - $this->object->getServiceAttributes( 'invalid', -1, self::$basket ); |
|
| 91 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Service\\Exception'); |
|
| 92 | + $this->object->getServiceAttributes('invalid', -1, self::$basket); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | public function testGetServicePrice() |
| 97 | 97 | { |
| 98 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 99 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
| 98 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 99 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
| 100 | 100 | |
| 101 | 101 | $service = $this->getServiceItem(); |
| 102 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
| 102 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
| 103 | 103 | |
| 104 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
| 105 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
| 104 | + $this->assertEquals('12.95', $price->getValue()); |
|
| 105 | + $this->assertEquals('1.99', $price->getCosts()); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | public function testGetServicePriceCache() |
| 110 | 110 | { |
| 111 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 112 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
| 111 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 112 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
| 113 | 113 | |
| 114 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
| 114 | + $services = $this->object->getServices('delivery', $basket); |
|
| 115 | 115 | |
| 116 | - if( ( $service = reset( $services ) ) === false ) { |
|
| 117 | - throw new \RuntimeException( 'No service item found' ); |
|
| 116 | + if (($service = reset($services)) === false) { |
|
| 117 | + throw new \RuntimeException('No service item found'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
| 120 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
| 121 | 121 | |
| 122 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
| 123 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
| 122 | + $this->assertEquals('12.95', $price->getValue()); |
|
| 123 | + $this->assertEquals('1.99', $price->getCosts()); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | public function testGetServicePriceNoItems() |
| 128 | 128 | { |
| 129 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 130 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
| 129 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 130 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
| 131 | 131 | |
| 132 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Service\\Exception' ); |
|
| 133 | - $this->object->getServicePrice( 'invalid', -1, $basket ); |
|
| 132 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Service\\Exception'); |
|
| 133 | + $this->object->getServicePrice('invalid', -1, $basket); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | public function testCheckServiceAttributes() |
| 138 | 138 | { |
| 139 | 139 | $service = $this->getServiceItem(); |
| 140 | - $attributes = $this->object->checkServiceAttributes( 'delivery', $service->getId(), array() ); |
|
| 140 | + $attributes = $this->object->checkServiceAttributes('delivery', $service->getId(), array()); |
|
| 141 | 141 | |
| 142 | - $this->assertEquals( array(), $attributes ); |
|
| 142 | + $this->assertEquals(array(), $attributes); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
@@ -148,21 +148,21 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | protected function getServiceItem() |
| 150 | 150 | { |
| 151 | - $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 151 | + $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 152 | 152 | |
| 153 | - $search = $serviceManager->createSearch( true ); |
|
| 153 | + $search = $serviceManager->createSearch(true); |
|
| 154 | 154 | $expr = array( |
| 155 | 155 | $search->getConditions(), |
| 156 | - $search->compare( '==', 'service.provider', 'Standard' ), |
|
| 157 | - $search->compare( '==', 'service.type.domain', 'service' ), |
|
| 158 | - $search->compare( '==', 'service.type.code', 'delivery' ), |
|
| 156 | + $search->compare('==', 'service.provider', 'Standard'), |
|
| 157 | + $search->compare('==', 'service.type.domain', 'service'), |
|
| 158 | + $search->compare('==', 'service.type.code', 'delivery'), |
|
| 159 | 159 | ); |
| 160 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 160 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 161 | 161 | |
| 162 | - $services = $serviceManager->searchItems( $search ); |
|
| 162 | + $services = $serviceManager->searchItems($search); |
|
| 163 | 163 | |
| 164 | - if( ( $service = reset( $services ) ) === false ) { |
|
| 165 | - throw new \RuntimeException( 'No service item found' ); |
|
| 164 | + if (($service = reset($services)) === false) { |
|
| 165 | + throw new \RuntimeException('No service item found'); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $service; |
@@ -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 \RuntimeException( 'Wrong expression' ); |
|
| 98 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 99 | + throw new \RuntimeException('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 \RuntimeException( 'Sortation not set' ); |
|
| 118 | + if (($item = reset($sort)) === false) { |
|
| 119 | + throw new \RuntimeException('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 \RuntimeException( 'Sortation not set' ); |
|
| 137 | + if (($item = reset($sort)) === false) { |
|
| 138 | + throw new \RuntimeException('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 \RuntimeException( 'Sortation not set' ); |
|
| 152 | + if (($item = reset($sort)) === false) { |
|
| 153 | + throw new \RuntimeException('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 \RuntimeException( 'Sortation not set' ); |
|
| 167 | + if (($item = reset($sort)) === false) { |
|
| 168 | + throw new \RuntimeException('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 \RuntimeException( 'Wrong expression' ); |
|
| 191 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 192 | + throw new \RuntimeException('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 \RuntimeException( 'Wrong expression' ); |
|
| 210 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 211 | + throw new \RuntimeException('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 \RuntimeException( 'Sortation not set' ); |
|
| 241 | + if (($item = reset($sort)) === false) { |
|
| 242 | + throw new \RuntimeException('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 \RuntimeException( 'Sortation not set' ); |
|
| 256 | + if (($item = reset($sort)) === false) { |
|
| 257 | + throw new \RuntimeException('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 \RuntimeException( 'Sortation not set' ); |
|
| 271 | + if (($item = reset($sort)) === false) { |
|
| 272 | + throw new \RuntimeException('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 \RuntimeException( 'Wrong expression' ); |
|
| 295 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 296 | + throw new \RuntimeException('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 \RuntimeException( 'Catalog item not found' ); |
|
| 314 | + if (($item = reset($items)) === false) { |
|
| 315 | + throw new \RuntimeException('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( 2, $total ); |
|
| 334 | - $this->assertEquals( 1, count( $results ) ); |
|
| 333 | + $this->assertEquals(2, $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 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 63 | 63 | * @return void |
| 64 | 64 | */ |
| 65 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 65 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 66 | 66 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
| 67 | - $stocktype = 'default' ); |
|
| 67 | + $stocktype = 'default'); |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param integer $position Position number (key) of the order product item |
| 74 | 74 | * @return void |
| 75 | 75 | */ |
| 76 | - public function deleteProduct( $position ); |
|
| 76 | + public function deleteProduct($position); |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | - public function editProduct( $position, $quantity, array $configAttributeCodes = array() ); |
|
| 87 | + public function editProduct($position, $quantity, array $configAttributeCodes = array()); |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | - public function addCoupon( $code ); |
|
| 97 | + public function addCoupon($code); |
|
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | - public function deleteCoupon( $code ); |
|
| 107 | + public function deleteCoupon($code); |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * if one of the keys is invalid when using an array with key/value pairs |
| 117 | 117 | * @return void |
| 118 | 118 | */ |
| 119 | - public function setAddress( $type, $value ); |
|
| 119 | + public function setAddress($type, $value); |
|
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -129,5 +129,5 @@ discard block |
||
| 129 | 129 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 130 | 130 | * @return void |
| 131 | 131 | */ |
| 132 | - public function setService( $type, $id, array $attributes = array() ); |
|
| 132 | + public function setService($type, $id, array $attributes = array()); |
|
| 133 | 133 | } |
@@ -41,27 +41,27 @@ |
||
| 41 | 41 | * @param string $stocktype Unique code of the stock type 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 $variantAttributeIds = array(), |
|
| 44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
| 45 | 45 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
| 46 | - $stocktype = 'default' ) |
|
| 46 | + $stocktype = 'default') |
|
| 47 | 47 | { |
| 48 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 48 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 49 | 49 | |
| 50 | - $search = $catalogListManager->createSearch( true ); |
|
| 50 | + $search = $catalogListManager->createSearch(true); |
|
| 51 | 51 | $expr = array( |
| 52 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
| 53 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
| 52 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
| 53 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
| 54 | 54 | $search->getConditions() |
| 55 | 55 | ); |
| 56 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 57 | - $search->setSlice( 0, 1 ); |
|
| 56 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 57 | + $search->setSlice(0, 1); |
|
| 58 | 58 | |
| 59 | - $result = $catalogListManager->searchItems( $search ); |
|
| 59 | + $result = $catalogListManager->searchItems($search); |
|
| 60 | 60 | |
| 61 | - if( reset( $result ) === false ) |
|
| 61 | + if (reset($result) === false) |
|
| 62 | 62 | { |
| 63 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
| 64 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 63 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
| 64 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $this->getController()->addProduct( |