@@ -150,7 +150,6 @@ |
||
| 150 | 150 | * Adds the delivery/payment service item based on the service ID. |
| 151 | 151 | * |
| 152 | 152 | * @param string $type Service type code like 'payment' or 'delivery' |
| 153 | - * @param string $id|null Unique ID of the service item or null to remove it |
|
| 154 | 153 | * @param array $attributes Associative list of key/value pairs containing the attributes selected or |
| 155 | 154 | * entered by the customer when choosing one of the delivery or payment options |
| 156 | 155 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param string $type Basket type |
| 51 | 51 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
| 52 | 52 | */ |
| 53 | - public function setType( $type ); |
|
| 53 | + public function setType($type); |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param boolean $default True to add default criteria (user logged in), false if not |
| 70 | 70 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
| 71 | 71 | */ |
| 72 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ); |
|
| 72 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true); |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 92 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 93 | 93 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
| 94 | - $stocktype = 'default' ); |
|
| 94 | + $stocktype = 'default'); |
|
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param integer $position Position number (key) of the order product item |
| 101 | 101 | * @return void |
| 102 | 102 | */ |
| 103 | - public function deleteProduct( $position ); |
|
| 103 | + public function deleteProduct($position); |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 112 | 112 | * @return void |
| 113 | 113 | */ |
| 114 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ); |
|
| 114 | + public function editProduct($position, $quantity, array $configAttributeCodes = []); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 122 | 122 | * @return void |
| 123 | 123 | */ |
| 124 | - public function addCoupon( $code ); |
|
| 124 | + public function addCoupon($code); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 132 | 132 | * @return void |
| 133 | 133 | */ |
| 134 | - public function deleteCoupon( $code ); |
|
| 134 | + public function deleteCoupon($code); |
|
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * if one of the keys is invalid when using an array with key/value pairs |
| 144 | 144 | * @return void |
| 145 | 145 | */ |
| 146 | - public function setAddress( $type, $value ); |
|
| 146 | + public function setAddress($type, $value); |
|
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * entered by the customer when choosing one of the delivery or payment options |
| 156 | 156 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 157 | 157 | */ |
| 158 | - public function addService( $type, $id, array $attributes = [] ); |
|
| 158 | + public function addService($type, $id, array $attributes = []); |
|
| 159 | 159 | |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -163,5 +163,5 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @param string $type Service type code like 'payment' or 'delivery' |
| 165 | 165 | */ |
| 166 | - public function deleteService( $type ); |
|
| 166 | + public function deleteService($type); |
|
| 167 | 167 | } |
@@ -455,7 +455,6 @@ |
||
| 455 | 455 | * Adds the delivery/payment service item based on the service ID. |
| 456 | 456 | * |
| 457 | 457 | * @param string $type Service type code like 'payment' or 'delivery' |
| 458 | - * @param string $id|null Unique ID of the service item or null to remove it |
|
| 459 | 458 | * @param array $attributes Associative list of key/value pairs containing the attributes selected or |
| 460 | 459 | * entered by the customer when choosing one of the delivery or payment options |
| 461 | 460 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
| 34 | 34 | * connections, logger, session, etc. |
| 35 | 35 | */ |
| 36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 37 | 37 | { |
| 38 | - parent::__construct( $context ); |
|
| 38 | + parent::__construct($context); |
|
| 39 | 39 | |
| 40 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
| 40 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | public function clear() |
| 50 | 50 | { |
| 51 | 51 | $this->baskets[$this->type] = $this->domainManager->createItem(); |
| 52 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
| 52 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
| 53 | 53 | |
| 54 | 54 | return $this; |
| 55 | 55 | } |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function get() |
| 64 | 64 | { |
| 65 | - if( !isset( $this->baskets[$this->type] ) ) |
|
| 65 | + if (!isset($this->baskets[$this->type])) |
|
| 66 | 66 | { |
| 67 | - $this->baskets[$this->type] = $this->domainManager->getSession( $this->type ); |
|
| 68 | - $this->checkLocale( $this->type ); |
|
| 67 | + $this->baskets[$this->type] = $this->domainManager->getSession($this->type); |
|
| 68 | + $this->checkLocale($this->type); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $this->baskets[$this->type]; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function save() |
| 81 | 81 | { |
| 82 | - if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { |
|
| 83 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
| 82 | + if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) { |
|
| 83 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param string $type Basket type |
| 94 | 94 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
| 95 | 95 | */ |
| 96 | - public function setType( $type ) |
|
| 96 | + public function setType($type) |
|
| 97 | 97 | { |
| 98 | 98 | $this->type = $type; |
| 99 | 99 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @category Developer |
| 128 | 128 | * @see controller/frontend/basket/limit-seconds |
| 129 | 129 | */ |
| 130 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
| 130 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
| 131 | 131 | |
| 132 | 132 | /** controller/frontend/basket/limit-seconds |
| 133 | 133 | * Order limitation time frame in seconds |
@@ -145,30 +145,30 @@ discard block |
||
| 145 | 145 | * @category Developer |
| 146 | 146 | * @see controller/frontend/basket/limit-count |
| 147 | 147 | */ |
| 148 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
| 148 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
| 149 | 149 | |
| 150 | 150 | $search = $this->domainManager->createSearch(); |
| 151 | 151 | $expr = [ |
| 152 | - $search->compare( '==', 'order.base.editor', $context->getEditor() ), |
|
| 153 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
| 152 | + $search->compare('==', 'order.base.editor', $context->getEditor()), |
|
| 153 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
| 154 | 154 | ]; |
| 155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 156 | - $search->setSlice( 0, 0 ); |
|
| 155 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 156 | + $search->setSlice(0, 0); |
|
| 157 | 157 | |
| 158 | - $this->domainManager->searchItems( $search, [], $total ); |
|
| 158 | + $this->domainManager->searchItems($search, [], $total); |
|
| 159 | 159 | |
| 160 | - if( $total > $count ) |
|
| 160 | + if ($total > $count) |
|
| 161 | 161 | { |
| 162 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' ); |
|
| 163 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 162 | + $msg = $context->getI18n()->dt('controller/frontend', 'Temporary order limit reached'); |
|
| 163 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | $basket = $this->get()->finish(); |
| 168 | - $basket->setCustomerId( (string) $context->getUserId() ); |
|
| 168 | + $basket->setCustomerId((string) $context->getUserId()); |
|
| 169 | 169 | |
| 170 | 170 | $this->domainManager->begin(); |
| 171 | - $this->domainManager->store( $basket ); |
|
| 171 | + $this->domainManager->store($basket); |
|
| 172 | 172 | $this->domainManager->commit(); |
| 173 | 173 | |
| 174 | 174 | return $basket; |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * @param boolean $default True to add default criteria (user logged in), false if not |
| 184 | 184 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
| 185 | 185 | */ |
| 186 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
| 186 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
| 187 | 187 | { |
| 188 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
| 188 | + return $this->domainManager->load($id, $parts, false, $default); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -205,34 +205,34 @@ discard block |
||
| 205 | 205 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 206 | 206 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 207 | 207 | */ |
| 208 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 208 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 209 | 209 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
| 210 | - $stocktype = 'default' ) |
|
| 210 | + $stocktype = 'default') |
|
| 211 | 211 | { |
| 212 | 212 | $attributeMap = [ |
| 213 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 213 | + 'custom' => array_keys($customAttributeValues), |
|
| 214 | 214 | 'config' => $configAttributeIds, |
| 215 | 215 | 'hidden' => $hiddenAttributeIds, |
| 216 | 216 | ]; |
| 217 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
| 217 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | $context = $this->getContext(); |
| 221 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 222 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
| 223 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 221 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 222 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
| 223 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 224 | 224 | |
| 225 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 226 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 225 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 226 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 227 | 227 | |
| 228 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
| 229 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) ); |
|
| 230 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
| 228 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
| 229 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds)); |
|
| 230 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
| 231 | 231 | |
| 232 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 233 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 232 | + $orderBaseProductItem->setAttributes($attr); |
|
| 233 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 234 | 234 | |
| 235 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
| 235 | + $this->get()->addProduct($orderBaseProductItem); |
|
| 236 | 236 | $this->save(); |
| 237 | 237 | } |
| 238 | 238 | |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @param integer $position Position number (key) of the order product item |
| 244 | 244 | */ |
| 245 | - public function deleteProduct( $position ) |
|
| 245 | + public function deleteProduct($position) |
|
| 246 | 246 | { |
| 247 | - $product = $this->get()->getProduct( $position ); |
|
| 247 | + $product = $this->get()->getProduct($position); |
|
| 248 | 248 | |
| 249 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 249 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 250 | 250 | { |
| 251 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually' ); |
|
| 252 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
| 251 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually'); |
|
| 252 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $this->get()->deleteProduct( $position ); |
|
| 255 | + $this->get()->deleteProduct($position); |
|
| 256 | 256 | $this->save(); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -266,33 +266,33 @@ discard block |
||
| 266 | 266 | * The 'stock'=>false option allows adding products without being in stock. |
| 267 | 267 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 268 | 268 | */ |
| 269 | - public function editProduct( $position, $quantity, array $options = [], |
|
| 270 | - array $configAttributeCodes = [] ) |
|
| 269 | + public function editProduct($position, $quantity, array $options = [], |
|
| 270 | + array $configAttributeCodes = []) |
|
| 271 | 271 | { |
| 272 | - $product = $this->get()->getProduct( $position ); |
|
| 272 | + $product = $this->get()->getProduct($position); |
|
| 273 | 273 | |
| 274 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
| 274 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
| 275 | 275 | { |
| 276 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be changed' ); |
|
| 277 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
| 276 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be changed'); |
|
| 277 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $product->setQuantity( $quantity ); |
|
| 280 | + $product->setQuantity($quantity); |
|
| 281 | 281 | |
| 282 | 282 | $attributes = $product->getAttributes(); |
| 283 | - foreach( $attributes as $key => $attribute ) |
|
| 283 | + foreach ($attributes as $key => $attribute) |
|
| 284 | 284 | { |
| 285 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
| 286 | - unset( $attributes[$key] ); |
|
| 285 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
| 286 | + unset($attributes[$key]); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | - $product->setAttributes( $attributes ); |
|
| 289 | + $product->setAttributes($attributes); |
|
| 290 | 290 | |
| 291 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 292 | - $productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ) ); |
|
| 293 | - $product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) ); |
|
| 291 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 292 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text')); |
|
| 293 | + $product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity)); |
|
| 294 | 294 | |
| 295 | - $this->get()->editProduct( $product, $position ); |
|
| 295 | + $this->get()->editProduct($product, $position); |
|
| 296 | 296 | |
| 297 | 297 | $this->save(); |
| 298 | 298 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @param string $code Coupon code entered by the user |
| 305 | 305 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 306 | 306 | */ |
| 307 | - public function addCoupon( $code ) |
|
| 307 | + public function addCoupon($code) |
|
| 308 | 308 | { |
| 309 | 309 | $context = $this->getContext(); |
| 310 | 310 | |
@@ -324,63 +324,63 @@ discard block |
||
| 324 | 324 | * @category User |
| 325 | 325 | * @category Developer |
| 326 | 326 | */ |
| 327 | - $allowed = $context->getConfig()->get( 'client/html/basket/standard/coupon/allowed', 1 ); // @deprecated |
|
| 328 | - $allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', $allowed ); |
|
| 327 | + $allowed = $context->getConfig()->get('client/html/basket/standard/coupon/allowed', 1); // @deprecated |
|
| 328 | + $allowed = $context->getConfig()->get('controller/frontend/basket/standard/coupon/allowed', $allowed); |
|
| 329 | 329 | |
| 330 | - if( $allowed <= count( $this->get()->getCoupons() ) ) |
|
| 330 | + if ($allowed <= count($this->get()->getCoupons())) |
|
| 331 | 331 | { |
| 332 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Number of coupon codes exceeds the limit' ); |
|
| 333 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 332 | + $msg = $context->getI18n()->dt('controller/frontend', 'Number of coupon codes exceeds the limit'); |
|
| 333 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | |
| 337 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
| 338 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
| 337 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
| 338 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
| 339 | 339 | |
| 340 | 340 | |
| 341 | - $search = $codeManager->createSearch( true ); |
|
| 341 | + $search = $codeManager->createSearch(true); |
|
| 342 | 342 | $expr = array( |
| 343 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
| 343 | + $search->compare('==', 'coupon.code.code', $code), |
|
| 344 | 344 | $search->getConditions(), |
| 345 | 345 | ); |
| 346 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 347 | - $search->setSlice( 0, 1 ); |
|
| 346 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 347 | + $search->setSlice(0, 1); |
|
| 348 | 348 | |
| 349 | - $result = $codeManager->searchItems( $search ); |
|
| 349 | + $result = $codeManager->searchItems($search); |
|
| 350 | 350 | |
| 351 | - if( ( $codeItem = reset( $result ) ) === false ) |
|
| 351 | + if (($codeItem = reset($result)) === false) |
|
| 352 | 352 | { |
| 353 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid or not available any more' ), $code ); |
|
| 354 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 353 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid or not available any more'), $code); |
|
| 354 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | |
| 358 | - $search = $manager->createSearch( true ); |
|
| 358 | + $search = $manager->createSearch(true); |
|
| 359 | 359 | $expr = array( |
| 360 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
| 360 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
| 361 | 361 | $search->getConditions(), |
| 362 | 362 | ); |
| 363 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 364 | - $search->setSlice( 0, 1 ); |
|
| 363 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 364 | + $search->setSlice(0, 1); |
|
| 365 | 365 | |
| 366 | - $result = $manager->searchItems( $search ); |
|
| 366 | + $result = $manager->searchItems($search); |
|
| 367 | 367 | |
| 368 | - if( ( $item = reset( $result ) ) === false ) |
|
| 368 | + if (($item = reset($result)) === false) |
|
| 369 | 369 | { |
| 370 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon for code "%1$s" is not available any more' ), $code ); |
|
| 371 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 370 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon for code "%1$s" is not available any more'), $code); |
|
| 371 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | |
| 375 | - $provider = $manager->getProvider( $item, $codeItem->getCode() ); |
|
| 375 | + $provider = $manager->getProvider($item, $codeItem->getCode()); |
|
| 376 | 376 | |
| 377 | - if( $provider->isAvailable( $this->get() ) !== true ) |
|
| 377 | + if ($provider->isAvailable($this->get()) !== true) |
|
| 378 | 378 | { |
| 379 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met' ), $code ); |
|
| 380 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 379 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met'), $code); |
|
| 380 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - $provider->addCoupon( $this->get() ); |
|
| 383 | + $provider->addCoupon($this->get()); |
|
| 384 | 384 | $this->save(); |
| 385 | 385 | } |
| 386 | 386 | |
@@ -391,24 +391,24 @@ discard block |
||
| 391 | 391 | * @param string $code Coupon code entered by the user |
| 392 | 392 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 393 | 393 | */ |
| 394 | - public function deleteCoupon( $code ) |
|
| 394 | + public function deleteCoupon($code) |
|
| 395 | 395 | { |
| 396 | 396 | $context = $this->getContext(); |
| 397 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' ); |
|
| 397 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'coupon'); |
|
| 398 | 398 | |
| 399 | 399 | $search = $manager->createSearch(); |
| 400 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
| 401 | - $search->setSlice( 0, 1 ); |
|
| 400 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
| 401 | + $search->setSlice(0, 1); |
|
| 402 | 402 | |
| 403 | - $result = $manager->searchItems( $search ); |
|
| 403 | + $result = $manager->searchItems($search); |
|
| 404 | 404 | |
| 405 | - if( ( $item = reset( $result ) ) === false ) |
|
| 405 | + if (($item = reset($result)) === false) |
|
| 406 | 406 | { |
| 407 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid' ); |
|
| 408 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $code ) ); |
|
| 407 | + $msg = $context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid'); |
|
| 408 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $code)); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
| 411 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
| 412 | 412 | $this->save(); |
| 413 | 413 | } |
| 414 | 414 | |
@@ -421,30 +421,30 @@ discard block |
||
| 421 | 421 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
| 422 | 422 | * if one of the keys is invalid when using an array with key/value pairs |
| 423 | 423 | */ |
| 424 | - public function setAddress( $type, $value ) |
|
| 424 | + public function setAddress($type, $value) |
|
| 425 | 425 | { |
| 426 | 426 | $context = $this->getContext(); |
| 427 | - $address = \Aimeos\MShop\Factory::createManager( $context, 'order/base/address' )->createItem(); |
|
| 428 | - $address->setType( $type ); |
|
| 427 | + $address = \Aimeos\MShop\Factory::createManager($context, 'order/base/address')->createItem(); |
|
| 428 | + $address->setType($type); |
|
| 429 | 429 | |
| 430 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
| 430 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
| 431 | 431 | { |
| 432 | - $address->copyFrom( $value ); |
|
| 433 | - $this->get()->setAddress( $address, $type ); |
|
| 432 | + $address->copyFrom($value); |
|
| 433 | + $this->get()->setAddress($address, $type); |
|
| 434 | 434 | } |
| 435 | - else if( is_array( $value ) ) |
|
| 435 | + else if (is_array($value)) |
|
| 436 | 436 | { |
| 437 | - $this->setAddressFromArray( $address, $value ); |
|
| 438 | - $this->get()->setAddress( $address, $type ); |
|
| 437 | + $this->setAddressFromArray($address, $value); |
|
| 438 | + $this->get()->setAddress($address, $type); |
|
| 439 | 439 | } |
| 440 | - else if( $value === null ) |
|
| 440 | + else if ($value === null) |
|
| 441 | 441 | { |
| 442 | - $this->get()->deleteAddress( $type ); |
|
| 442 | + $this->get()->deleteAddress($type); |
|
| 443 | 443 | } |
| 444 | 444 | else |
| 445 | 445 | { |
| 446 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' ); |
|
| 447 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) ); |
|
| 446 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid value for address type "%1$s"'); |
|
| 447 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $type)); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $this->save(); |
@@ -460,42 +460,42 @@ discard block |
||
| 460 | 460 | * entered by the customer when choosing one of the delivery or payment options |
| 461 | 461 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 462 | 462 | */ |
| 463 | - public function addService( $type, $id, array $attributes = [] ) |
|
| 463 | + public function addService($type, $id, array $attributes = []) |
|
| 464 | 464 | { |
| 465 | 465 | $context = $this->getContext(); |
| 466 | 466 | |
| 467 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
| 468 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
| 467 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
| 468 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
| 469 | 469 | |
| 470 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
| 471 | - $result = $provider->checkConfigFE( $attributes ); |
|
| 472 | - $unknown = array_diff_key( $attributes, $result ); |
|
| 470 | + $provider = $serviceManager->getProvider($serviceItem); |
|
| 471 | + $result = $provider->checkConfigFE($attributes); |
|
| 472 | + $unknown = array_diff_key($attributes, $result); |
|
| 473 | 473 | |
| 474 | - if( count( $unknown ) > 0 ) |
|
| 474 | + if (count($unknown) > 0) |
|
| 475 | 475 | { |
| 476 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Unknown attributes "%1$s"' ); |
|
| 477 | - $msg = sprintf( $msg, implode( '","', array_keys( $unknown ) ) ); |
|
| 478 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 476 | + $msg = $context->getI18n()->dt('controller/frontend', 'Unknown attributes "%1$s"'); |
|
| 477 | + $msg = sprintf($msg, implode('","', array_keys($unknown))); |
|
| 478 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - foreach( $result as $key => $value ) |
|
| 481 | + foreach ($result as $key => $value) |
|
| 482 | 482 | { |
| 483 | - if( $value !== null ) { |
|
| 484 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
| 483 | + if ($value !== null) { |
|
| 484 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
| 488 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
| 489 | 489 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
| 490 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
| 490 | + $orderServiceItem->copyFrom($serviceItem); |
|
| 491 | 491 | |
| 492 | 492 | // remove service rebate of original price |
| 493 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
| 494 | - $orderServiceItem->setPrice( $price ); |
|
| 493 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
| 494 | + $orderServiceItem->setPrice($price); |
|
| 495 | 495 | |
| 496 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
| 496 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
| 497 | 497 | |
| 498 | - $this->get()->addService( $orderServiceItem, $type ); |
|
| 498 | + $this->get()->addService($orderServiceItem, $type); |
|
| 499 | 499 | $this->save(); |
| 500 | 500 | } |
| 501 | 501 | |
@@ -505,9 +505,9 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @param string $type Service type code like 'payment' or 'delivery' |
| 507 | 507 | */ |
| 508 | - public function deleteService( $type ) |
|
| 508 | + public function deleteService($type) |
|
| 509 | 509 | { |
| 510 | - $this->get()->deleteService( $type ); |
|
| 510 | + $this->get()->deleteService($type); |
|
| 511 | 511 | $this->save(); |
| 512 | 512 | } |
| 513 | 513 | |
@@ -520,18 +520,18 @@ discard block |
||
| 520 | 520 | * an address item. |
| 521 | 521 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 522 | 522 | */ |
| 523 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
| 523 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
| 524 | 524 | { |
| 525 | - foreach( $map as $key => $value ) { |
|
| 526 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
| 525 | + foreach ($map as $key => $value) { |
|
| 526 | + $map[$key] = strip_tags($value); // prevent XSS |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - $errors = $address->fromArray( $map ); |
|
| 529 | + $errors = $address->fromArray($map); |
|
| 530 | 530 | |
| 531 | - if( count( $errors ) > 0 ) |
|
| 531 | + if (count($errors) > 0) |
|
| 532 | 532 | { |
| 533 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Invalid address properties, please check your input' ); |
|
| 534 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
| 533 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Invalid address properties, please check your input'); |
|
| 534 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | } |
@@ -30,18 +30,18 @@ discard block |
||
| 30 | 30 | * @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
| 31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
| 32 | 32 | */ |
| 33 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 33 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context) |
|
| 34 | 34 | { |
| 35 | 35 | $iface = '\Aimeos\Controller\Frontend\Basket\Iface'; |
| 36 | - if( !( $controller instanceof $iface ) ) |
|
| 36 | + if (!($controller instanceof $iface)) |
|
| 37 | 37 | { |
| 38 | - $msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface ); |
|
| 39 | - throw new \Aimeos\Controller\Frontend\Exception( $msg ); |
|
| 38 | + $msg = sprintf('Class "%1$s" does not implement interface "%2$s"', get_class($controller), $iface); |
|
| 39 | + throw new \Aimeos\Controller\Frontend\Exception($msg); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $this->controller = $controller; |
| 43 | 43 | |
| 44 | - parent::__construct( $context ); |
|
| 44 | + parent::__construct($context); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @return mixed Returns the value of the called method |
| 54 | 54 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
| 55 | 55 | */ |
| 56 | - public function __call( $name, array $param ) |
|
| 56 | + public function __call($name, array $param) |
|
| 57 | 57 | { |
| 58 | - return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
| 58 | + return @call_user_func_array(array($this->controller, $name), $param); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | * @param string $type Basket type |
| 98 | 98 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
| 99 | 99 | */ |
| 100 | - public function setType( $type ) |
|
| 100 | + public function setType($type) |
|
| 101 | 101 | { |
| 102 | - $this->controller->setType( $type ); |
|
| 102 | + $this->controller->setType($type); |
|
| 103 | 103 | return $this; |
| 104 | 104 | } |
| 105 | 105 | |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | * @param boolean $default True to add default criteria (user logged in), false if not |
| 124 | 124 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
| 125 | 125 | */ |
| 126 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
| 126 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
| 127 | 127 | { |
| 128 | - return $this->controller->load( $id, $parts, $default ); |
|
| 128 | + return $this->controller->load($id, $parts, $default); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 151 | 151 | * @return void |
| 152 | 152 | */ |
| 153 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 153 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
| 154 | 154 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
| 155 | - $stocktype = 'default' ) |
|
| 155 | + $stocktype = 'default') |
|
| 156 | 156 | { |
| 157 | 157 | $this->controller->addProduct( |
| 158 | 158 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | * @param integer $position Position number (key) of the order product item |
| 168 | 168 | * @return void |
| 169 | 169 | */ |
| 170 | - public function deleteProduct( $position ) |
|
| 170 | + public function deleteProduct($position) |
|
| 171 | 171 | { |
| 172 | - $this->controller->deleteProduct( $position ); |
|
| 172 | + $this->controller->deleteProduct($position); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
| 183 | 183 | * @return void |
| 184 | 184 | */ |
| 185 | - public function editProduct( $position, $quantity, array $options = [], array $configAttributeCodes = [] ) |
|
| 185 | + public function editProduct($position, $quantity, array $options = [], array $configAttributeCodes = []) |
|
| 186 | 186 | { |
| 187 | - $this->controller->editProduct( $position, $quantity, $options, $configAttributeCodes ); |
|
| 187 | + $this->controller->editProduct($position, $quantity, $options, $configAttributeCodes); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
| 196 | 196 | * @return void |
| 197 | 197 | */ |
| 198 | - public function addCoupon( $code ) |
|
| 198 | + public function addCoupon($code) |
|
| 199 | 199 | { |
| 200 | - $this->controller->addCoupon( $code ); |
|
| 200 | + $this->controller->addCoupon($code); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
| 209 | 209 | * @return void |
| 210 | 210 | */ |
| 211 | - public function deleteCoupon( $code ) |
|
| 211 | + public function deleteCoupon($code) |
|
| 212 | 212 | { |
| 213 | - $this->controller->deleteCoupon( $code ); |
|
| 213 | + $this->controller->deleteCoupon($code); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | * if one of the keys is invalid when using an array with key/value pairs |
| 224 | 224 | * @return void |
| 225 | 225 | */ |
| 226 | - public function setAddress( $type, $value ) |
|
| 226 | + public function setAddress($type, $value) |
|
| 227 | 227 | { |
| 228 | - $this->controller->setAddress( $type, $value ); |
|
| 228 | + $this->controller->setAddress($type, $value); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
| 240 | 240 | * @return void |
| 241 | 241 | */ |
| 242 | - public function addService( $type, $id, array $attributes = [] ) |
|
| 242 | + public function addService($type, $id, array $attributes = []) |
|
| 243 | 243 | { |
| 244 | - $this->controller->addService( $type, $id, $attributes ); |
|
| 244 | + $this->controller->addService($type, $id, $attributes); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @param string $type Service type code like 'payment' or 'delivery' |
| 252 | 252 | */ |
| 253 | - public function deleteService( $type ) |
|
| 253 | + public function deleteService($type) |
|
| 254 | 254 | { |
| 255 | - $this->controller->deleteService( $type ); |
|
| 255 | + $this->controller->deleteService($type); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -31,46 +31,46 @@ 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 | 44 | |
| 45 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 46 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 45 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 46 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
| 47 | 47 | |
| 48 | 48 | // customers can pay what they would like to pay |
| 49 | - if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null ) |
|
| 49 | + if (($attr = $product->getAttributeItem('price', 'custom')) !== null) |
|
| 50 | 50 | { |
| 51 | 51 | $amount = $attr->getValue(); |
| 52 | 52 | |
| 53 | - if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 ) { |
|
| 54 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid price value "%1$s"', $amount ) ); |
|
| 53 | + if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) { |
|
| 54 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid price value "%1$s"', $amount)); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $price->setValue( $amount ); |
|
| 57 | + $price->setValue($amount); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // add prices of (optional) attributes |
| 61 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
| 61 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
| 62 | 62 | { |
| 63 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
| 63 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
| 64 | 64 | |
| 65 | - if( count( $prices ) > 0 ) |
|
| 65 | + if (count($prices) > 0) |
|
| 66 | 66 | { |
| 67 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
| 68 | - $price->addItem( $attrPrice ); |
|
| 67 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
| 68 | + $price->addItem($attrPrice); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // remove product rebate of original price in favor to rebates granted for the order |
| 73 | - $price->setRebate( '0.00' ); |
|
| 73 | + $price->setRebate('0.00'); |
|
| 74 | 74 | |
| 75 | 75 | return $price; |
| 76 | 76 | } |
@@ -84,42 +84,42 @@ discard block |
||
| 84 | 84 | * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values |
| 85 | 85 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
| 86 | 86 | */ |
| 87 | - protected function checkListRef( $prodId, $domain, array $refMap ) |
|
| 87 | + protected function checkListRef($prodId, $domain, array $refMap) |
|
| 88 | 88 | { |
| 89 | - if( empty( $refMap ) ) { |
|
| 89 | + if (empty($refMap)) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 94 | - $search = $productManager->createSearch( true ); |
|
| 93 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 94 | + $search = $productManager->createSearch(true); |
|
| 95 | 95 | |
| 96 | 96 | $expr = array( |
| 97 | - $search->compare( '==', 'product.id', $prodId ), |
|
| 97 | + $search->compare('==', 'product.id', $prodId), |
|
| 98 | 98 | $search->getConditions(), |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - foreach( $refMap as $listType => $refIds ) |
|
| 101 | + foreach ($refMap as $listType => $refIds) |
|
| 102 | 102 | { |
| 103 | - if( empty( $refIds ) ) { |
|
| 103 | + if (empty($refIds)) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - foreach( $refIds as $key => $refId ) { |
|
| 107 | + foreach ($refIds as $key => $refId) { |
|
| 108 | 108 | $refIds[$key] = (string) $refId; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds ); |
|
| 112 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 111 | + $param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds); |
|
| 112 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 113 | 113 | |
| 114 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
| 114 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 117 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 118 | 118 | |
| 119 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
| 119 | + if (count($productManager->searchItems($search, [])) === 0) |
|
| 120 | 120 | { |
| 121 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
| 122 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 121 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
| 122 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
@@ -134,34 +134,34 @@ discard block |
||
| 134 | 134 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
| 135 | 135 | * @deprecated Use checkListRef() instead |
| 136 | 136 | */ |
| 137 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
| 137 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
| 138 | 138 | { |
| 139 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 140 | - $search = $productManager->createSearch( true ); |
|
| 139 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 140 | + $search = $productManager->createSearch(true); |
|
| 141 | 141 | |
| 142 | 142 | $expr = array( |
| 143 | - $search->compare( '==', 'product.id', $prodId ), |
|
| 143 | + $search->compare('==', 'product.id', $prodId), |
|
| 144 | 144 | $search->getConditions(), |
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - if( count( $refIds ) > 0 ) |
|
| 147 | + if (count($refIds) > 0) |
|
| 148 | 148 | { |
| 149 | - foreach( $refIds as $key => $refId ) { |
|
| 149 | + foreach ($refIds as $key => $refId) { |
|
| 150 | 150 | $refIds[$key] = (string) $refId; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $param = array( $domain, $listTypeId, $refIds ); |
|
| 154 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 153 | + $param = array($domain, $listTypeId, $refIds); |
|
| 154 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 155 | 155 | |
| 156 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
| 156 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 159 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 160 | 160 | |
| 161 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
| 161 | + if (count($productManager->searchItems($search, [])) === 0) |
|
| 162 | 162 | { |
| 163 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
| 164 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 163 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
| 164 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -171,41 +171,41 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @param string $type Basket type |
| 173 | 173 | */ |
| 174 | - protected function checkLocale( $type ) |
|
| 174 | + protected function checkLocale($type) |
|
| 175 | 175 | { |
| 176 | 176 | $errors = []; |
| 177 | 177 | $context = $this->getContext(); |
| 178 | 178 | $session = $context->getSession(); |
| 179 | 179 | $locale = $this->get()->getLocale(); |
| 180 | 180 | |
| 181 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
| 181 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
| 182 | 182 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
| 183 | 183 | |
| 184 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
| 184 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
| 185 | 185 | { |
| 186 | - $locParts = explode( '|', $localeStr ); |
|
| 187 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
| 188 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
| 189 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
| 186 | + $locParts = explode('|', $localeStr); |
|
| 187 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
| 188 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
| 189 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
| 190 | 190 | |
| 191 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 192 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
| 191 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
| 192 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
| 193 | 193 | |
| 194 | 194 | $context = clone $context; |
| 195 | - $context->setLocale( $locale ); |
|
| 195 | + $context->setLocale($locale); |
|
| 196 | 196 | |
| 197 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
| 198 | - $basket = $manager->getSession( $type ); |
|
| 197 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
| 198 | + $basket = $manager->getSession($type); |
|
| 199 | 199 | |
| 200 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
| 201 | - $this->copyServices( $basket, $errors ); |
|
| 202 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
| 203 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
| 200 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
| 201 | + $this->copyServices($basket, $errors); |
|
| 202 | + $this->copyProducts($basket, $errors, $localeKey); |
|
| 203 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
| 204 | 204 | |
| 205 | - $manager->setSession( $basket, $type ); |
|
| 205 | + $manager->setSession($basket, $type); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
| 208 | + $session->set('aimeos/basket/locale', $localeKey); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -217,20 +217,20 @@ discard block |
||
| 217 | 217 | * @param string $localeKey Unique identifier of the site, language and currency |
| 218 | 218 | * @return array Associative list of errors occured |
| 219 | 219 | */ |
| 220 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 220 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 221 | 221 | { |
| 222 | - foreach( $basket->getAddresses() as $type => $item ) |
|
| 222 | + foreach ($basket->getAddresses() as $type => $item) |
|
| 223 | 223 | { |
| 224 | 224 | try |
| 225 | 225 | { |
| 226 | - $this->setAddress( $type, $item->toArray() ); |
|
| 227 | - $basket->deleteAddress( $type ); |
|
| 226 | + $this->setAddress($type, $item->toArray()); |
|
| 227 | + $basket->deleteAddress($type); |
|
| 228 | 228 | } |
| 229 | - catch( \Exception $e ) |
|
| 229 | + catch (\Exception $e) |
|
| 230 | 230 | { |
| 231 | 231 | $logger = $this->getContext()->getLogger(); |
| 232 | 232 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
| 233 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 233 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 234 | 234 | $errors['address'][$type] = $e->getMessage(); |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -247,20 +247,20 @@ discard block |
||
| 247 | 247 | * @param string $localeKey Unique identifier of the site, language and currency |
| 248 | 248 | * @return array Associative list of errors occured |
| 249 | 249 | */ |
| 250 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 250 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 251 | 251 | { |
| 252 | - foreach( $basket->getCoupons() as $code => $list ) |
|
| 252 | + foreach ($basket->getCoupons() as $code => $list) |
|
| 253 | 253 | { |
| 254 | 254 | try |
| 255 | 255 | { |
| 256 | - $this->addCoupon( $code ); |
|
| 257 | - $basket->deleteCoupon( $code, true ); |
|
| 256 | + $this->addCoupon($code); |
|
| 257 | + $basket->deleteCoupon($code, true); |
|
| 258 | 258 | } |
| 259 | - catch( \Exception $e ) |
|
| 259 | + catch (\Exception $e) |
|
| 260 | 260 | { |
| 261 | 261 | $logger = $this->getContext()->getLogger(); |
| 262 | 262 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 263 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 263 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 264 | 264 | $errors['coupon'][$code] = $e->getMessage(); |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | * @param string $localeKey Unique identifier of the site, language and currency |
| 278 | 278 | * @return array Associative list of errors occured |
| 279 | 279 | */ |
| 280 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
| 280 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
| 281 | 281 | { |
| 282 | - foreach( $basket->getProducts() as $pos => $product ) |
|
| 282 | + foreach ($basket->getProducts() as $pos => $product) |
|
| 283 | 283 | { |
| 284 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
| 284 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | $attrIds = []; |
| 291 | 291 | |
| 292 | - foreach( $product->getAttributes() as $attrItem ) { |
|
| 292 | + foreach ($product->getAttributes() as $attrItem) { |
|
| 293 | 293 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -297,23 +297,23 @@ discard block |
||
| 297 | 297 | $product->getProductId(), |
| 298 | 298 | $product->getQuantity(), |
| 299 | 299 | [], |
| 300 | - $this->getValue( $attrIds, 'variant', [] ), |
|
| 301 | - $this->getValue( $attrIds, 'config', [] ), |
|
| 302 | - $this->getValue( $attrIds, 'hidden', [] ), |
|
| 303 | - $this->getValue( $attrIds, 'custom', [] ), |
|
| 300 | + $this->getValue($attrIds, 'variant', []), |
|
| 301 | + $this->getValue($attrIds, 'config', []), |
|
| 302 | + $this->getValue($attrIds, 'hidden', []), |
|
| 303 | + $this->getValue($attrIds, 'custom', []), |
|
| 304 | 304 | $product->getStockType() |
| 305 | 305 | ); |
| 306 | 306 | |
| 307 | - $basket->deleteProduct( $pos ); |
|
| 307 | + $basket->deleteProduct($pos); |
|
| 308 | 308 | } |
| 309 | - catch( \Exception $e ) |
|
| 309 | + catch (\Exception $e) |
|
| 310 | 310 | { |
| 311 | 311 | $code = $product->getProductCode(); |
| 312 | 312 | $logger = $this->getContext()->getLogger(); |
| 313 | 313 | $errors['product'][$pos] = $e->getMessage(); |
| 314 | 314 | |
| 315 | 315 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 316 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 316 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
@@ -328,24 +328,24 @@ discard block |
||
| 328 | 328 | * @param array $errors Associative list of previous errors |
| 329 | 329 | * @return array Associative list of errors occured |
| 330 | 330 | */ |
| 331 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
| 331 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
| 332 | 332 | { |
| 333 | - foreach( $basket->getServices() as $type => $list ) |
|
| 333 | + foreach ($basket->getServices() as $type => $list) |
|
| 334 | 334 | { |
| 335 | - foreach( $list as $item ) |
|
| 335 | + foreach ($list as $item) |
|
| 336 | 336 | { |
| 337 | 337 | try |
| 338 | 338 | { |
| 339 | 339 | $attributes = []; |
| 340 | 340 | |
| 341 | - foreach( $item->getAttributes() as $attrItem ) { |
|
| 341 | + foreach ($item->getAttributes() as $attrItem) { |
|
| 342 | 342 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $this->addService( $type, $item->getServiceId(), $attributes ); |
|
| 346 | - $basket->deleteService( $type ); |
|
| 345 | + $this->addService($type, $item->getServiceId(), $attributes); |
|
| 346 | + $basket->deleteService($type); |
|
| 347 | 347 | } |
| 348 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 348 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
@@ -365,36 +365,36 @@ discard block |
||
| 365 | 365 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 366 | 366 | * @deprecated Use getOrderProductAttributes(), checkReferences() and calcPrice() instead |
| 367 | 367 | */ |
| 368 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 369 | - array $attributeIds, $type, array $attributeValues = [] ) |
|
| 368 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
| 369 | + array $attributeIds, $type, array $attributeValues = []) |
|
| 370 | 370 | { |
| 371 | - if( empty( $attributeIds ) ) { |
|
| 371 | + if (empty($attributeIds)) { |
|
| 372 | 372 | return []; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
| 376 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
| 375 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
| 376 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
| 377 | 377 | |
| 378 | 378 | $list = []; |
| 379 | 379 | $context = $this->getContext(); |
| 380 | 380 | |
| 381 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
| 382 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
| 381 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
| 382 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
| 383 | 383 | |
| 384 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 384 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 385 | 385 | { |
| 386 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
| 386 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
| 387 | 387 | |
| 388 | - if( !empty( $prices ) ) { |
|
| 389 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
| 388 | + if (!empty($prices)) { |
|
| 389 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | $item = $orderProductAttributeManager->createItem(); |
| 393 | - $item->copyFrom( $attrItem ); |
|
| 394 | - $item->setType( $type ); |
|
| 393 | + $item->copyFrom($attrItem); |
|
| 394 | + $item->setType($type); |
|
| 395 | 395 | |
| 396 | - if( isset( $attributeValues[$id] ) ) { |
|
| 397 | - $item->setValue( $attributeValues[$id] ); |
|
| 396 | + if (isset($attributeValues[$id])) { |
|
| 397 | + $item->setValue($attributeValues[$id]); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | $list[] = $item; |
@@ -412,31 +412,31 @@ discard block |
||
| 412 | 412 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
| 413 | 413 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
| 414 | 414 | */ |
| 415 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
| 415 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
| 416 | 416 | { |
| 417 | - if( empty( $attributeIds ) ) { |
|
| 417 | + if (empty($attributeIds)) { |
|
| 418 | 418 | return []; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 421 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 422 | 422 | |
| 423 | - $search = $attributeManager->createSearch( true ); |
|
| 423 | + $search = $attributeManager->createSearch(true); |
|
| 424 | 424 | $expr = array( |
| 425 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
| 425 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
| 426 | 426 | $search->getConditions(), |
| 427 | 427 | ); |
| 428 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 429 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 428 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 429 | + $search->setSlice(0, 0x7fffffff); |
|
| 430 | 430 | |
| 431 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
| 431 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
| 432 | 432 | |
| 433 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
| 433 | + if (count($attrItems) !== count($attributeIds)) |
|
| 434 | 434 | { |
| 435 | - $expected = implode( ',', $attributeIds ); |
|
| 436 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
| 437 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
| 435 | + $expected = implode(',', $attributeIds); |
|
| 436 | + $actual = implode(',', array_keys($attrItems)); |
|
| 437 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
| 438 | 438 | |
| 439 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 439 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | return $attrItems; |
@@ -449,31 +449,31 @@ discard block |
||
| 449 | 449 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
| 450 | 450 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
| 451 | 451 | */ |
| 452 | - protected function getAttributeItems( array $orderAttributes ) |
|
| 452 | + protected function getAttributeItems(array $orderAttributes) |
|
| 453 | 453 | { |
| 454 | - if( empty( $orderAttributes ) ) { |
|
| 454 | + if (empty($orderAttributes)) { |
|
| 455 | 455 | return []; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 459 | - $search = $attributeManager->createSearch( true ); |
|
| 458 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 459 | + $search = $attributeManager->createSearch(true); |
|
| 460 | 460 | $expr = []; |
| 461 | 461 | |
| 462 | - foreach( $orderAttributes as $item ) |
|
| 462 | + foreach ($orderAttributes as $item) |
|
| 463 | 463 | { |
| 464 | 464 | $tmp = array( |
| 465 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 466 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
| 467 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
| 468 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
| 469 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
| 465 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 466 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
| 467 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
| 468 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
| 469 | + $search->compare('>', 'attribute.type.status', 0), |
|
| 470 | 470 | $search->getConditions(), |
| 471 | 471 | ); |
| 472 | - $expr[] = $search->combine( '&&', $tmp ); |
|
| 472 | + $expr[] = $search->combine('&&', $tmp); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
| 476 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
| 475 | + $search->setConditions($search->combine('||', $expr)); |
|
| 476 | + return $attributeManager->searchItems($search, array('price')); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | |
@@ -488,23 +488,23 @@ discard block |
||
| 488 | 488 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
| 489 | 489 | * @deprecated Use getItem() or findItem() instead |
| 490 | 490 | */ |
| 491 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
| 491 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
| 492 | 492 | { |
| 493 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
| 493 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
| 494 | 494 | |
| 495 | - $search = $manager->createSearch( true ); |
|
| 495 | + $search = $manager->createSearch(true); |
|
| 496 | 496 | $expr = array( |
| 497 | - $search->compare( '==', $key, $value ), |
|
| 497 | + $search->compare('==', $key, $value), |
|
| 498 | 498 | $search->getConditions(), |
| 499 | 499 | ); |
| 500 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 500 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 501 | 501 | |
| 502 | - $result = $manager->searchItems( $search, $ref ); |
|
| 502 | + $result = $manager->searchItems($search, $ref); |
|
| 503 | 503 | |
| 504 | - if( ( $item = reset( $result ) ) === false ) |
|
| 504 | + if (($item = reset($result)) === false) |
|
| 505 | 505 | { |
| 506 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
| 507 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 506 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
| 507 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | return $item; |
@@ -519,27 +519,27 @@ discard block |
||
| 519 | 519 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
| 520 | 520 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 521 | 521 | */ |
| 522 | - protected function getOrderProductAttributes( $type, array $attributeIds, array $attributeValues = [] ) |
|
| 522 | + protected function getOrderProductAttributes($type, array $attributeIds, array $attributeValues = []) |
|
| 523 | 523 | { |
| 524 | - if( empty( $attributeIds ) ) { |
|
| 524 | + if (empty($attributeIds)) { |
|
| 525 | 525 | return []; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - foreach( $attributeValues as $key => $value ) { |
|
| 528 | + foreach ($attributeValues as $key => $value) { |
|
| 529 | 529 | $attributeValues[(string) $key] = $value; // Workaround for PHP bug #74739 |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | $list = []; |
| 533 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
| 533 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
| 534 | 534 | |
| 535 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
| 535 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
| 536 | 536 | { |
| 537 | 537 | $item = $manager->createItem(); |
| 538 | - $item->copyFrom( $attrItem ); |
|
| 539 | - $item->setType( $type ); |
|
| 538 | + $item->copyFrom($attrItem); |
|
| 539 | + $item->setType($type); |
|
| 540 | 540 | |
| 541 | - if( isset( $attributeValues[$id] ) ) { |
|
| 542 | - $item->setValue( $attributeValues[$id] ); |
|
| 541 | + if (isset($attributeValues[$id])) { |
|
| 542 | + $item->setValue($attributeValues[$id]); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | $list[] = $item; |
@@ -556,21 +556,21 @@ discard block |
||
| 556 | 556 | * @param string $code Code of the list type |
| 557 | 557 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
| 558 | 558 | */ |
| 559 | - protected function getProductListTypeItem( $domain, $code ) |
|
| 559 | + protected function getProductListTypeItem($domain, $code) |
|
| 560 | 560 | { |
| 561 | - if( empty( $this->listTypeItems ) ) |
|
| 561 | + if (empty($this->listTypeItems)) |
|
| 562 | 562 | { |
| 563 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
| 563 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
| 564 | 564 | |
| 565 | - foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) { |
|
| 566 | - $this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item; |
|
| 565 | + foreach ($manager->searchItems($manager->createSearch(true)) as $item) { |
|
| 566 | + $this->listTypeItems[$item->getDomain()][$item->getCode()] = $item; |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - if( !isset( $this->listTypeItems[$domain][$code] ) ) |
|
| 570 | + if (!isset($this->listTypeItems[$domain][$code])) |
|
| 571 | 571 | { |
| 572 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
| 573 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 572 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
| 573 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | return $this->listTypeItems[$domain][$code]; |
@@ -585,43 +585,43 @@ discard block |
||
| 585 | 585 | * @param array $domains Names of the domain items that should be fetched too |
| 586 | 586 | * @return array List of products matching the given attributes |
| 587 | 587 | */ |
| 588 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 589 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
| 588 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 589 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
| 590 | 590 | { |
| 591 | 591 | $subProductIds = []; |
| 592 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
| 592 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
| 593 | 593 | $subProductIds[] = $item->getId(); |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - if( count( $subProductIds ) === 0 ) { |
|
| 596 | + if (count($subProductIds) === 0) { |
|
| 597 | 597 | return []; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 601 | - $search = $productManager->createSearch( true ); |
|
| 600 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 601 | + $search = $productManager->createSearch(true); |
|
| 602 | 602 | |
| 603 | 603 | $expr = array( |
| 604 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 604 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 605 | 605 | $search->getConditions(), |
| 606 | 606 | ); |
| 607 | 607 | |
| 608 | - if( count( $variantAttributeIds ) > 0 ) |
|
| 608 | + if (count($variantAttributeIds) > 0) |
|
| 609 | 609 | { |
| 610 | - foreach( $variantAttributeIds as $key => $id ) { |
|
| 610 | + foreach ($variantAttributeIds as $key => $id) { |
|
| 611 | 611 | $variantAttributeIds[$key] = (string) $id; |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
| 614 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
| 615 | 615 | |
| 616 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
| 617 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 616 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
| 617 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 618 | 618 | |
| 619 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
| 619 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 622 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 623 | 623 | |
| 624 | - return $productManager->searchItems( $search, $domains ); |
|
| 624 | + return $productManager->searchItems($search, $domains); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | |
@@ -633,9 +633,9 @@ discard block |
||
| 633 | 633 | * @param mixed $default Default value if no value is available for the given name |
| 634 | 634 | * @return mixed Value from the array or default value |
| 635 | 635 | */ |
| 636 | - protected function getValue( array $values, $name, $default = null ) |
|
| 636 | + protected function getValue(array $values, $name, $default = null) |
|
| 637 | 637 | { |
| 638 | - if( isset( $values[$name] ) ) { |
|
| 638 | + if (isset($values[$name])) { |
|
| 639 | 639 | return $values[$name]; |
| 640 | 640 | } |
| 641 | 641 | |
@@ -225,8 +225,7 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | $this->setAddress( $type, $item->toArray() ); |
| 227 | 227 | $basket->deleteAddress( $type ); |
| 228 | - } |
|
| 229 | - catch( \Exception $e ) |
|
| 228 | + } catch( \Exception $e ) |
|
| 230 | 229 | { |
| 231 | 230 | $logger = $this->getContext()->getLogger(); |
| 232 | 231 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -255,8 +254,7 @@ discard block |
||
| 255 | 254 | { |
| 256 | 255 | $this->addCoupon( $code ); |
| 257 | 256 | $basket->deleteCoupon( $code, true ); |
| 258 | - } |
|
| 259 | - catch( \Exception $e ) |
|
| 257 | + } catch( \Exception $e ) |
|
| 260 | 258 | { |
| 261 | 259 | $logger = $this->getContext()->getLogger(); |
| 262 | 260 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -305,8 +303,7 @@ discard block |
||
| 305 | 303 | ); |
| 306 | 304 | |
| 307 | 305 | $basket->deleteProduct( $pos ); |
| 308 | - } |
|
| 309 | - catch( \Exception $e ) |
|
| 306 | + } catch( \Exception $e ) |
|
| 310 | 307 | { |
| 311 | 308 | $code = $product->getProductCode(); |
| 312 | 309 | $logger = $this->getContext()->getLogger(); |
@@ -344,8 +341,7 @@ discard block |
||
| 344 | 341 | |
| 345 | 342 | $this->addService( $type, $item->getServiceId(), $attributes ); |
| 346 | 343 | $basket->deleteService( $type ); |
| 347 | - } |
|
| 348 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 344 | + } catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 349 | 345 | } |
| 350 | 346 | } |
| 351 | 347 | |
@@ -19,112 +19,112 @@ discard block |
||
| 19 | 19 | public static function setUpBeforeClass() |
| 20 | 20 | { |
| 21 | 21 | $context = \TestHelperFrontend::getContext(); |
| 22 | - self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' ); |
|
| 22 | + self::$testItem = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TESTP'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | protected function setUp() |
| 27 | 27 | { |
| 28 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 28 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 29 | 29 | |
| 30 | 30 | $this->context = \TestHelperFrontend::getContext(); |
| 31 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 31 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | protected function tearDown() |
| 36 | 36 | { |
| 37 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 37 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 38 | 38 | \Aimeos\MShop\Factory::clear(); |
| 39 | 39 | |
| 40 | 40 | $this->object->clear(); |
| 41 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
| 41 | + $this->context->getSession()->set('aimeos', []); |
|
| 42 | 42 | |
| 43 | - unset( $this->context, $this->object ); |
|
| 43 | + unset($this->context, $this->object); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | public function testClear() |
| 48 | 48 | { |
| 49 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 49 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 50 | 50 | $this->object->clear(); |
| 51 | 51 | |
| 52 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
| 52 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | public function testGet() |
| 57 | 57 | { |
| 58 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
| 58 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | public function testSave() |
| 63 | 63 | { |
| 64 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 65 | - ->setConstructorArgs( [$this->context] ) |
|
| 66 | - ->setMethods( ['setSession'] ) |
|
| 64 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 65 | + ->setConstructorArgs([$this->context]) |
|
| 66 | + ->setMethods(['setSession']) |
|
| 67 | 67 | ->getMock(); |
| 68 | 68 | |
| 69 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 69 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 70 | 70 | |
| 71 | - $stub->expects( $this->exactly( 2 ) )->method( 'setSession' ); |
|
| 71 | + $stub->expects($this->exactly(2))->method('setSession'); |
|
| 72 | 72 | |
| 73 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 74 | - $object->addProduct( self::$testItem->getId(), 2 ); |
|
| 73 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 74 | + $object->addProduct(self::$testItem->getId(), 2); |
|
| 75 | 75 | $object->save(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | public function testSetType() |
| 80 | 80 | { |
| 81 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) ); |
|
| 81 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType('test')); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | public function testStore() |
| 86 | 86 | { |
| 87 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 88 | - ->setConstructorArgs( [$this->context] ) |
|
| 89 | - ->setMethods( ['store'] ) |
|
| 87 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 88 | + ->setConstructorArgs([$this->context]) |
|
| 89 | + ->setMethods(['store']) |
|
| 90 | 90 | ->getMock(); |
| 91 | 91 | |
| 92 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 92 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 93 | 93 | |
| 94 | - $stub->expects( $this->once() )->method( 'store' ); |
|
| 94 | + $stub->expects($this->once())->method('store'); |
|
| 95 | 95 | |
| 96 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 96 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 97 | 97 | $object->store(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | public function testStoreLimit() |
| 102 | 102 | { |
| 103 | - $this->context->setEditor( 'core:unittest' ); |
|
| 103 | + $this->context->setEditor('core:unittest'); |
|
| 104 | 104 | $config = $this->context->getConfig(); |
| 105 | - $config->set( 'controller/frontend/basket/limit-count', 0 ); |
|
| 106 | - $config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 ); |
|
| 105 | + $config->set('controller/frontend/basket/limit-count', 0); |
|
| 106 | + $config->set('controller/frontend/basket/limit-seconds', 86400 * 365); |
|
| 107 | 107 | |
| 108 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 108 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 109 | 109 | |
| 110 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
| 110 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
| 111 | 111 | $object->store(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | public function testLoad() |
| 116 | 116 | { |
| 117 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 118 | - ->setConstructorArgs( [$this->context] ) |
|
| 119 | - ->setMethods( ['load'] ) |
|
| 117 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 118 | + ->setConstructorArgs([$this->context]) |
|
| 119 | + ->setMethods(['load']) |
|
| 120 | 120 | ->getMock(); |
| 121 | 121 | |
| 122 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 122 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 123 | 123 | |
| 124 | - $stub->expects( $this->once() )->method( 'load' ) |
|
| 125 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 124 | + $stub->expects($this->once())->method('load') |
|
| 125 | + ->will($this->returnValue($stub->createItem())); |
|
| 126 | 126 | |
| 127 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 127 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 128 | 128 | $object->load( -1 ); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,311 +132,311 @@ discard block |
||
| 132 | 132 | public function testAddDeleteProduct() |
| 133 | 133 | { |
| 134 | 134 | $basket = $this->object->get(); |
| 135 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 135 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 136 | 136 | |
| 137 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'default' ); |
|
| 138 | - $item2 = $this->object->get()->getProduct( 0 ); |
|
| 139 | - $this->object->deleteProduct( 0 ); |
|
| 137 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'default'); |
|
| 138 | + $item2 = $this->object->get()->getProduct(0); |
|
| 139 | + $this->object->deleteProduct(0); |
|
| 140 | 140 | |
| 141 | - $this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
| 142 | - $this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
| 141 | + $this->assertEquals(0, count($basket->getProducts())); |
|
| 142 | + $this->assertEquals('CNC', $item2->getProductCode()); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | public function testAddProductCustomAttribute() |
| 147 | 147 | { |
| 148 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 148 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 149 | 149 | |
| 150 | 150 | $search = $attributeManager->createSearch(); |
| 151 | 151 | $expr = array( |
| 152 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 153 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
| 152 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 153 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
| 154 | 154 | ); |
| 155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 155 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 156 | 156 | |
| 157 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 157 | + $attributes = $attributeManager->searchItems($search); |
|
| 158 | 158 | |
| 159 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 160 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 159 | + if (($attrItem = reset($attributes)) === false) { |
|
| 160 | + throw new \RuntimeException('Attribute not found'); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
| 163 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
| 164 | 164 | |
| 165 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
| 165 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
| 166 | 166 | $basket = $this->object->get(); |
| 167 | 167 | |
| 168 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 169 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
| 168 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 169 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | public function testAddProductCustomPrice() |
| 174 | 174 | { |
| 175 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 175 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 176 | 176 | |
| 177 | 177 | $search = $attributeManager->createSearch(); |
| 178 | 178 | $expr = array( |
| 179 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 180 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
| 179 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 180 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
| 181 | 181 | ); |
| 182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 182 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 183 | 183 | |
| 184 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 184 | + $attributes = $attributeManager->searchItems($search); |
|
| 185 | 185 | |
| 186 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 186 | + if (($attrItem = reset($attributes)) === false) { |
|
| 187 | + throw new \RuntimeException('Attribute not found'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $attrValues = array( $attrItem->getId() => '0.01' ); |
|
| 190 | + $attrValues = array($attrItem->getId() => '0.01'); |
|
| 191 | 191 | |
| 192 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
| 192 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
| 193 | 193 | $basket = $this->object->get(); |
| 194 | 194 | |
| 195 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 196 | - $this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() ); |
|
| 195 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 196 | + $this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue()); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | public function testAddProductCustomPriceException() |
| 201 | 201 | { |
| 202 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 202 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 203 | 203 | |
| 204 | 204 | $search = $attributeManager->createSearch(); |
| 205 | 205 | $expr = array( |
| 206 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 207 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
| 206 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 207 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
| 208 | 208 | ); |
| 209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 209 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 210 | 210 | |
| 211 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 211 | + $attributes = $attributeManager->searchItems($search); |
|
| 212 | 212 | |
| 213 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 214 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 213 | + if (($attrItem = reset($attributes)) === false) { |
|
| 214 | + throw new \RuntimeException('Attribute not found'); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - $attrValues = array( $attrItem->getId() => ',' ); |
|
| 217 | + $attrValues = array($attrItem->getId() => ','); |
|
| 218 | 218 | |
| 219 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
| 220 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
| 219 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
| 220 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | public function testAddProductAttributeNotAssigned() |
| 225 | 225 | { |
| 226 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 226 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 227 | 227 | |
| 228 | 228 | $search = $attributeManager->createSearch(); |
| 229 | 229 | $expr = array( |
| 230 | - $search->compare( '==', 'attribute.code', '30' ), |
|
| 231 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
| 230 | + $search->compare('==', 'attribute.code', '30'), |
|
| 231 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
| 232 | 232 | ); |
| 233 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 233 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 234 | 234 | |
| 235 | - $attribute = $attributeManager->searchItems( $search ); |
|
| 235 | + $attribute = $attributeManager->searchItems($search); |
|
| 236 | 236 | |
| 237 | - if( empty( $attribute ) ) { |
|
| 238 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 237 | + if (empty($attribute)) { |
|
| 238 | + throw new \RuntimeException('Attribute not found'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $hiddenAttrIds = array_keys( $attribute ); |
|
| 242 | - $configAttrIds = array_keys( $attribute ); |
|
| 241 | + $hiddenAttrIds = array_keys($attribute); |
|
| 242 | + $configAttrIds = array_keys($attribute); |
|
| 243 | 243 | |
| 244 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 245 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds ); |
|
| 244 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 245 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | public function testAddProductNegativeQuantityException() |
| 250 | 250 | { |
| 251 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
| 252 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
| 251 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
| 252 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
| 256 | 256 | public function testAddProductNoPriceException() |
| 257 | 257 | { |
| 258 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
| 258 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
| 259 | 259 | |
| 260 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 261 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 260 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 261 | + $this->object->addProduct($item->getId(), 1); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
| 265 | 265 | public function testAddProductConfigAttributeException() |
| 266 | 266 | { |
| 267 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 268 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) ); |
|
| 267 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 268 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], array( -1 )); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | |
| 272 | 272 | public function testAddProductLowQuantityPriceException() |
| 273 | 273 | { |
| 274 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 274 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 275 | 275 | |
| 276 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 277 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 276 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 277 | + $this->object->addProduct($item->getId(), 1); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | public function testAddProductHigherQuantities() |
| 282 | 282 | { |
| 283 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 283 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 284 | 284 | |
| 285 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' ); |
|
| 285 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'unit_type3'); |
|
| 286 | 286 | |
| 287 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
| 288 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 287 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
| 288 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | public function testDeleteProductFlagError() |
| 293 | 293 | { |
| 294 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 294 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 295 | 295 | |
| 296 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 297 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 296 | + $item = $this->object->get()->getProduct(0); |
|
| 297 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 298 | 298 | |
| 299 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 300 | - $this->object->deleteProduct( 0 ); |
|
| 299 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 300 | + $this->object->deleteProduct(0); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | public function testEditProduct() |
| 305 | 305 | { |
| 306 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
| 306 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
| 307 | 307 | |
| 308 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 309 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
| 308 | + $item = $this->object->get()->getProduct(0); |
|
| 309 | + $this->assertEquals(1, $item->getQuantity()); |
|
| 310 | 310 | |
| 311 | - $this->object->editProduct( 0, 4 ); |
|
| 311 | + $this->object->editProduct(0, 4); |
|
| 312 | 312 | |
| 313 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 314 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 315 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
| 313 | + $item = $this->object->get()->getProduct(0); |
|
| 314 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 315 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | public function testEditProductAttributes() |
| 320 | 320 | { |
| 321 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 321 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 322 | 322 | |
| 323 | 323 | $search = $attributeManager->createSearch(); |
| 324 | 324 | $conditions = array( |
| 325 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 326 | - $search->combine( '||', array( |
|
| 327 | - $search->combine( '&&', array( |
|
| 328 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
| 329 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
| 330 | - ) ), |
|
| 331 | - $search->combine( '&&', array( |
|
| 332 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
| 333 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
| 334 | - ) ), |
|
| 335 | - ) ) |
|
| 325 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 326 | + $search->combine('||', array( |
|
| 327 | + $search->combine('&&', array( |
|
| 328 | + $search->compare('==', 'attribute.code', 'xs'), |
|
| 329 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
| 330 | + )), |
|
| 331 | + $search->combine('&&', array( |
|
| 332 | + $search->compare('==', 'attribute.code', 'white'), |
|
| 333 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
| 334 | + )), |
|
| 335 | + )) |
|
| 336 | 336 | ); |
| 337 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
| 338 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 337 | + $search->setConditions($search->combine('&&', $conditions)); |
|
| 338 | + $attributes = $attributeManager->searchItems($search); |
|
| 339 | 339 | |
| 340 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
| 341 | - throw new \RuntimeException( 'No attributes available' ); |
|
| 340 | + if (($attribute = reset($attributes)) === false) { |
|
| 341 | + throw new \RuntimeException('No attributes available'); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | |
| 345 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
| 345 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
| 346 | 346 | |
| 347 | - $this->object->addProduct( $item->getId(), 1, [], [], array_keys( $attributes ) ); |
|
| 348 | - $this->object->editProduct( 0, 4 ); |
|
| 347 | + $this->object->addProduct($item->getId(), 1, [], [], array_keys($attributes)); |
|
| 348 | + $this->object->editProduct(0, 4); |
|
| 349 | 349 | |
| 350 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 351 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
| 352 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 350 | + $item = $this->object->get()->getProduct(0); |
|
| 351 | + $this->assertEquals(2, count($item->getAttributes())); |
|
| 352 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 353 | 353 | |
| 354 | 354 | |
| 355 | - $this->object->editProduct( 0, 3, [], array( $attribute->getType() ) ); |
|
| 355 | + $this->object->editProduct(0, 3, [], array($attribute->getType())); |
|
| 356 | 356 | |
| 357 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 358 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
| 359 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
| 360 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
| 357 | + $item = $this->object->get()->getProduct(0); |
|
| 358 | + $this->assertEquals(3, $item->getQuantity()); |
|
| 359 | + $this->assertEquals(1, count($item->getAttributes())); |
|
| 360 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | public function testEditProductFlagError() |
| 365 | 365 | { |
| 366 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 366 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 367 | 367 | |
| 368 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 369 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 368 | + $item = $this->object->get()->getProduct(0); |
|
| 369 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 370 | 370 | |
| 371 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 372 | - $this->object->editProduct( 0, 4 ); |
|
| 371 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 372 | + $this->object->editProduct(0, 4); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
| 376 | 376 | public function testAddCoupon() |
| 377 | 377 | { |
| 378 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 379 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 378 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 379 | + $this->object->addCoupon('GHIJ'); |
|
| 380 | 380 | |
| 381 | 381 | $basket = $this->object->get(); |
| 382 | 382 | |
| 383 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
| 383 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | |
| 387 | 387 | public function testAddCouponExceedCount() |
| 388 | 388 | { |
| 389 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 390 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 389 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 390 | + $this->object->addCoupon('GHIJ'); |
|
| 391 | 391 | |
| 392 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 393 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 392 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 393 | + $this->object->addCoupon('GHIJ'); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | |
| 397 | 397 | public function testAddCouponInvalidCode() |
| 398 | 398 | { |
| 399 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 400 | - $this->object->addCoupon( 'invalid' ); |
|
| 399 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 400 | + $this->object->addCoupon('invalid'); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | public function testAddCouponMissingRequirements() |
| 405 | 405 | { |
| 406 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 407 | - $this->object->addCoupon( 'OPQR' ); |
|
| 406 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 407 | + $this->object->addCoupon('OPQR'); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | |
| 411 | 411 | public function testDeleteCoupon() |
| 412 | 412 | { |
| 413 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 414 | - $this->object->addCoupon( '90AB' ); |
|
| 415 | - $this->object->deleteCoupon( '90AB' ); |
|
| 413 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 414 | + $this->object->addCoupon('90AB'); |
|
| 415 | + $this->object->deleteCoupon('90AB'); |
|
| 416 | 416 | |
| 417 | 417 | $basket = $this->object->get(); |
| 418 | 418 | |
| 419 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
| 419 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | |
| 423 | 423 | public function testSetAddressDelete() |
| 424 | 424 | { |
| 425 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
| 425 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
| 426 | 426 | |
| 427 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
| 428 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 427 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
| 428 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | |
| 432 | 432 | public function testSetBillingAddressByItem() |
| 433 | 433 | { |
| 434 | - $item = $this->getAddress( 'Example company' ); |
|
| 434 | + $item = $this->getAddress('Example company'); |
|
| 435 | 435 | |
| 436 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
| 436 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
| 437 | 437 | |
| 438 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 439 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 438 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 439 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | |
@@ -464,37 +464,37 @@ discard block |
||
| 464 | 464 | 'order.base.address.flag' => 0, |
| 465 | 465 | ); |
| 466 | 466 | |
| 467 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
| 467 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
| 468 | 468 | |
| 469 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 470 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 471 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 472 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 469 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 470 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 471 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 472 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | |
| 476 | 476 | public function testSetBillingAddressByArrayError() |
| 477 | 477 | { |
| 478 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 479 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
| 478 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 479 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | |
| 483 | 483 | public function testSetBillingAddressParameterError() |
| 484 | 484 | { |
| 485 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 486 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
| 485 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 486 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | |
| 490 | 490 | public function testSetDeliveryAddressByItem() |
| 491 | 491 | { |
| 492 | - $item = $this->getAddress( 'Example company' ); |
|
| 492 | + $item = $this->getAddress('Example company'); |
|
| 493 | 493 | |
| 494 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
| 494 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
| 495 | 495 | |
| 496 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 497 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 496 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 497 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | |
@@ -521,121 +521,121 @@ discard block |
||
| 521 | 521 | 'order.base.address.website' => 'www.example.com', |
| 522 | 522 | 'order.base.address.flag' => 0, |
| 523 | 523 | ); |
| 524 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
| 524 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
| 525 | 525 | |
| 526 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 527 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 528 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 529 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 526 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 527 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 528 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 529 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | |
| 533 | 533 | public function testSetDeliveryAddressByArrayError() |
| 534 | 534 | { |
| 535 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 536 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
| 535 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 536 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | |
| 540 | 540 | public function testSetDeliveryAddressTypeError() |
| 541 | 541 | { |
| 542 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 543 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
| 542 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 543 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | |
| 547 | 547 | public function testSetServicePayment() |
| 548 | 548 | { |
| 549 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 550 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
| 549 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 550 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
| 551 | 551 | |
| 552 | - $this->object->addService( 'payment', $service->getId(), [] ); |
|
| 553 | - $item = $this->object->get()->getService( 'payment', 'unitpaymentcode' )->getCode(); |
|
| 554 | - $this->assertEquals( 'unitpaymentcode', $item ); |
|
| 552 | + $this->object->addService('payment', $service->getId(), []); |
|
| 553 | + $item = $this->object->get()->getService('payment', 'unitpaymentcode')->getCode(); |
|
| 554 | + $this->assertEquals('unitpaymentcode', $item); |
|
| 555 | 555 | |
| 556 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 557 | - $this->object->addService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
| 556 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 557 | + $this->object->addService('payment', $service->getId(), array('prepay' => true)); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | |
| 561 | 561 | public function testSetDeliveryOption() |
| 562 | 562 | { |
| 563 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 564 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 563 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 564 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 565 | 565 | |
| 566 | - $this->object->addService( 'delivery', $service->getId(), [] ); |
|
| 567 | - $item = $this->object->get()->getService( 'delivery', 'unitcode' ); |
|
| 568 | - $this->assertEquals( 'unitcode', $item->getCode() ); |
|
| 566 | + $this->object->addService('delivery', $service->getId(), []); |
|
| 567 | + $item = $this->object->get()->getService('delivery', 'unitcode'); |
|
| 568 | + $this->assertEquals('unitcode', $item->getCode()); |
|
| 569 | 569 | |
| 570 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 571 | - $this->object->addService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
| 570 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 571 | + $this->object->addService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | |
| 575 | 575 | public function testCheckLocale() |
| 576 | 576 | { |
| 577 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 578 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
| 579 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 577 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 578 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
| 579 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 580 | 580 | |
| 581 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 582 | - $this->object->addCoupon( 'OPQR' ); |
|
| 581 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 582 | + $this->object->addCoupon('OPQR'); |
|
| 583 | 583 | |
| 584 | - $this->object->addService( 'payment', $payment->getId() ); |
|
| 585 | - $this->object->addService( 'delivery', $delivery->getId() ); |
|
| 584 | + $this->object->addService('payment', $payment->getId()); |
|
| 585 | + $this->object->addService('delivery', $delivery->getId()); |
|
| 586 | 586 | |
| 587 | 587 | $basket = $this->object->get(); |
| 588 | 588 | $price = $basket->getPrice(); |
| 589 | 589 | |
| 590 | - foreach( $basket->getProducts() as $product ) |
|
| 590 | + foreach ($basket->getProducts() as $product) |
|
| 591 | 591 | { |
| 592 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 593 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
| 592 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 593 | + $product->getPrice()->setCurrencyId('CHF'); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - $basket->getService( 'delivery', 'unitcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 597 | - $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 598 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
| 599 | - $price->setCurrencyId( 'CHF' ); |
|
| 596 | + $basket->getService('delivery', 'unitcode')->getPrice()->setCurrencyId('CHF'); |
|
| 597 | + $basket->getService('payment', 'unitpaymentcode')->getPrice()->setCurrencyId('CHF'); |
|
| 598 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
| 599 | + $price->setCurrencyId('CHF'); |
|
| 600 | 600 | |
| 601 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
| 602 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
| 601 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
| 602 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
| 603 | 603 | |
| 604 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
| 605 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
| 604 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
| 605 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
| 606 | 606 | |
| 607 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
| 607 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
| 608 | 608 | |
| 609 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 609 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 610 | 610 | $basket = $object->get(); |
| 611 | 611 | |
| 612 | - foreach( $basket->getProducts() as $product ) |
|
| 612 | + foreach ($basket->getProducts() as $product) |
|
| 613 | 613 | { |
| 614 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
| 615 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 614 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
| 615 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $this->assertEquals( 'EUR', $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->getCurrencyId() ); |
|
| 619 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery', 'unitcode' )->getPrice()->getCurrencyId() ); |
|
| 620 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
| 621 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
| 618 | + $this->assertEquals('EUR', $basket->getService('payment', 'unitpaymentcode')->getPrice()->getCurrencyId()); |
|
| 619 | + $this->assertEquals('EUR', $basket->getService('delivery', 'unitcode')->getPrice()->getCurrencyId()); |
|
| 620 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
| 621 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | |
| 625 | 625 | /** |
| 626 | 626 | * @param string $company |
| 627 | 627 | */ |
| 628 | - protected function getAddress( $company ) |
|
| 628 | + protected function getAddress($company) |
|
| 629 | 629 | { |
| 630 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
| 631 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
| 630 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
| 631 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
| 632 | 632 | |
| 633 | 633 | $search = $addressManager->createSearch(); |
| 634 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
| 635 | - $items = $addressManager->searchItems( $search ); |
|
| 634 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
| 635 | + $items = $addressManager->searchItems($search); |
|
| 636 | 636 | |
| 637 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 638 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
| 637 | + if (($item = reset($items)) === false) { |
|
| 638 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | return $item; |
@@ -21,46 +21,46 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | protected function tearDown() |
| 23 | 23 | { |
| 24 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
| 24 | + $this->context->getSession()->set('aimeos', []); |
|
| 25 | 25 | |
| 26 | - unset( $this->context ); |
|
| 26 | + unset($this->context); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | public function testCheckLocale() |
| 31 | 31 | { |
| 32 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 33 | - ->setConstructorArgs( [$this->context] ) |
|
| 34 | - ->setMethods( null ) |
|
| 32 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 33 | + ->setConstructorArgs([$this->context]) |
|
| 34 | + ->setMethods(null) |
|
| 35 | 35 | ->getMock(); |
| 36 | 36 | |
| 37 | - $this->context->getSession()->set( 'aimeos/basket/locale', 'unittest|en|EUR' ); |
|
| 38 | - $this->access( 'checkLocale' )->invokeArgs( $object, ['unittest'] ); |
|
| 37 | + $this->context->getSession()->set('aimeos/basket/locale', 'unittest|en|EUR'); |
|
| 38 | + $this->access('checkLocale')->invokeArgs($object, ['unittest']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | public function testCopyAddresses() |
| 43 | 43 | { |
| 44 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 44 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 45 | 45 | $ordBaseItem = $manager->createItem(); |
| 46 | 46 | |
| 47 | - $address = $this->getAddress( 'Example company' ); |
|
| 48 | - $ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 47 | + $address = $this->getAddress('Example company'); |
|
| 48 | + $ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 52 | - ->setConstructorArgs( [$this->context] ) |
|
| 53 | - ->setMethods( null ) |
|
| 51 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 52 | + ->setConstructorArgs([$this->context]) |
|
| 53 | + ->setMethods(null) |
|
| 54 | 54 | ->getMock(); |
| 55 | 55 | |
| 56 | - $result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 56 | + $result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - $this->assertEquals( ['test'], $result ); |
|
| 60 | - $this->assertEquals( 1, count( $object->get()->getAddresses() ) ); |
|
| 59 | + $this->assertEquals(['test'], $result); |
|
| 60 | + $this->assertEquals(1, count($object->get()->getAddresses())); |
|
| 61 | 61 | |
| 62 | - $addr = $object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 63 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr ); |
|
| 62 | + $addr = $object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 63 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr); |
|
| 64 | 64 | |
| 65 | 65 | $object->clear(); |
| 66 | 66 | } |
@@ -68,54 +68,54 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function testCopyAddressesException() |
| 70 | 70 | { |
| 71 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 71 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 72 | 72 | $ordBaseItem = $manager->createItem(); |
| 73 | 73 | |
| 74 | - $address = $this->getAddress( 'Example company' ); |
|
| 75 | - $ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 74 | + $address = $this->getAddress('Example company'); |
|
| 75 | + $ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 79 | - ->setConstructorArgs( [$this->context] ) |
|
| 80 | - ->setMethods( ['setAddress'] ) |
|
| 78 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 79 | + ->setConstructorArgs([$this->context]) |
|
| 80 | + ->setMethods(['setAddress']) |
|
| 81 | 81 | ->getMock(); |
| 82 | 82 | |
| 83 | - $object->expects( $this->once() )->method( 'setAddress' )->will( $this->throwException( new \Exception() ) ); |
|
| 83 | + $object->expects($this->once())->method('setAddress')->will($this->throwException(new \Exception())); |
|
| 84 | 84 | |
| 85 | - $result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 85 | + $result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 86 | 86 | |
| 87 | - $this->assertEquals( 1, count( $result ) ); |
|
| 88 | - $this->assertArrayHasKey( 'address', $result ); |
|
| 87 | + $this->assertEquals(1, count($result)); |
|
| 88 | + $this->assertArrayHasKey('address', $result); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | public function testCopyCoupon() |
| 93 | 93 | { |
| 94 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 94 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 95 | 95 | $ordBaseItem = $manager->createItem(); |
| 96 | 96 | |
| 97 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC', ['price'] ); |
|
| 98 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
| 99 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
| 97 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC', ['price']); |
|
| 98 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
| 99 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
| 100 | 100 | |
| 101 | - $priceItems = $product->getRefItems( 'price' ); |
|
| 102 | - $ordProdItem->setPrice( reset( $priceItems ) ); |
|
| 101 | + $priceItems = $product->getRefItems('price'); |
|
| 102 | + $ordProdItem->setPrice(reset($priceItems)); |
|
| 103 | 103 | |
| 104 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
| 105 | - $ordBaseItem->addCoupon( 'OPQR', [] ); |
|
| 104 | + $ordBaseItem->addProduct($ordProdItem); |
|
| 105 | + $ordBaseItem->addCoupon('OPQR', []); |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 109 | - ->setConstructorArgs( [$this->context] ) |
|
| 110 | - ->setMethods( null ) |
|
| 108 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 109 | + ->setConstructorArgs([$this->context]) |
|
| 110 | + ->setMethods(null) |
|
| 111 | 111 | ->getMock(); |
| 112 | 112 | |
| 113 | - $object->addProduct( $product->getId() ); |
|
| 113 | + $object->addProduct($product->getId()); |
|
| 114 | 114 | |
| 115 | - $result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 115 | + $result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - $this->assertEquals( ['test'], $result ); |
|
| 118 | + $this->assertEquals(['test'], $result); |
|
| 119 | 119 | |
| 120 | 120 | $object->clear(); |
| 121 | 121 | } |
@@ -123,48 +123,48 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public function testCopyCouponException() |
| 125 | 125 | { |
| 126 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 126 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 127 | 127 | $ordBaseItem = $manager->createItem(); |
| 128 | 128 | |
| 129 | - $ordBaseItem->addCoupon( '90AB', [] ); |
|
| 129 | + $ordBaseItem->addCoupon('90AB', []); |
|
| 130 | 130 | |
| 131 | 131 | |
| 132 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 133 | - ->setConstructorArgs( [$this->context] ) |
|
| 134 | - ->setMethods( ['addCoupon'] ) |
|
| 132 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 133 | + ->setConstructorArgs([$this->context]) |
|
| 134 | + ->setMethods(['addCoupon']) |
|
| 135 | 135 | ->getMock(); |
| 136 | 136 | |
| 137 | - $object->expects( $this->once() )->method( 'addCoupon' )->will( $this->throwException( new \Exception() ) ); |
|
| 137 | + $object->expects($this->once())->method('addCoupon')->will($this->throwException(new \Exception())); |
|
| 138 | 138 | |
| 139 | - $result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 139 | + $result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 140 | 140 | |
| 141 | - $this->assertEquals( 1, count( $result ) ); |
|
| 142 | - $this->assertArrayHasKey( 'coupon', $result ); |
|
| 141 | + $this->assertEquals(1, count($result)); |
|
| 142 | + $this->assertArrayHasKey('coupon', $result); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | public function testCopyProduct() |
| 147 | 147 | { |
| 148 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 148 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 149 | 149 | $ordBaseItem = $manager->createItem(); |
| 150 | 150 | |
| 151 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 152 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
| 153 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
| 154 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
| 151 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 152 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
| 153 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
| 154 | + $ordBaseItem->addProduct($ordProdItem); |
|
| 155 | 155 | |
| 156 | 156 | |
| 157 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 158 | - ->setConstructorArgs( [$this->context] ) |
|
| 159 | - ->setMethods( null ) |
|
| 157 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 158 | + ->setConstructorArgs([$this->context]) |
|
| 159 | + ->setMethods(null) |
|
| 160 | 160 | ->getMock(); |
| 161 | 161 | |
| 162 | - $result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 162 | + $result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 163 | 163 | |
| 164 | 164 | |
| 165 | - $this->assertEquals( ['test'], $result ); |
|
| 166 | - $this->assertEquals( 1, count( $object->get()->getProducts() ) ); |
|
| 167 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct( 0 ) ); |
|
| 165 | + $this->assertEquals(['test'], $result); |
|
| 166 | + $this->assertEquals(1, count($object->get()->getProducts())); |
|
| 167 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct(0)); |
|
| 168 | 168 | |
| 169 | 169 | $object->clear(); |
| 170 | 170 | } |
@@ -172,58 +172,58 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | public function testCopyProductException() |
| 174 | 174 | { |
| 175 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 175 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 176 | 176 | $ordBaseItem = $manager->createItem(); |
| 177 | 177 | |
| 178 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 179 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
| 180 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
| 181 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
| 178 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 179 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
| 180 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
| 181 | + $ordBaseItem->addProduct($ordProdItem); |
|
| 182 | 182 | |
| 183 | 183 | |
| 184 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 185 | - ->setConstructorArgs( [$this->context] ) |
|
| 186 | - ->setMethods( ['addProduct'] ) |
|
| 184 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 185 | + ->setConstructorArgs([$this->context]) |
|
| 186 | + ->setMethods(['addProduct']) |
|
| 187 | 187 | ->getMock(); |
| 188 | 188 | |
| 189 | - $object->expects( $this->once() )->method( 'addProduct' )->will( $this->throwException( new \Exception() ) ); |
|
| 189 | + $object->expects($this->once())->method('addProduct')->will($this->throwException(new \Exception())); |
|
| 190 | 190 | |
| 191 | - $result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 191 | + $result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 192 | 192 | |
| 193 | - $this->assertEquals( 1, count( $result ) ); |
|
| 194 | - $this->assertArrayHasKey( 'product', $result ); |
|
| 193 | + $this->assertEquals(1, count($result)); |
|
| 194 | + $this->assertArrayHasKey('product', $result); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | |
| 198 | 198 | public function testCopyServices() |
| 199 | 199 | { |
| 200 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 200 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 201 | 201 | $ordBaseItem = $manager->createItem(); |
| 202 | 202 | |
| 203 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 204 | - $ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' ); |
|
| 203 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 204 | + $ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service'); |
|
| 205 | 205 | |
| 206 | - $serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 207 | - $ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem ); |
|
| 206 | + $serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 207 | + $ordServItem = $ordServManager->createItem()->copyFrom($serviceItem); |
|
| 208 | 208 | |
| 209 | - $ordBaseItem->addService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
| 209 | + $ordBaseItem->addService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
| 210 | 210 | |
| 211 | 211 | |
| 212 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 213 | - ->setConstructorArgs( [$this->context] ) |
|
| 214 | - ->setMethods( null ) |
|
| 212 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 213 | + ->setConstructorArgs([$this->context]) |
|
| 214 | + ->setMethods(null) |
|
| 215 | 215 | ->getMock(); |
| 216 | 216 | |
| 217 | - $result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 217 | + $result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - $this->assertEquals( ['test'], $result ); |
|
| 221 | - $this->assertEquals( 1, count( $object->get()->getServices() ) ); |
|
| 220 | + $this->assertEquals(['test'], $result); |
|
| 221 | + $this->assertEquals(1, count($object->get()->getServices())); |
|
| 222 | 222 | |
| 223 | - $services = $object->get()->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
| 223 | + $services = $object->get()->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
| 224 | 224 | |
| 225 | - foreach( $services as $service ) { |
|
| 226 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Service\Iface', $service ); |
|
| 225 | + foreach ($services as $service) { |
|
| 226 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Service\Iface', $service); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | $object->clear(); |
@@ -232,77 +232,77 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | public function testCopyServicesException() |
| 234 | 234 | { |
| 235 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 235 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 236 | 236 | $ordBaseItem = $manager->createItem(); |
| 237 | 237 | |
| 238 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 239 | - $ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' ); |
|
| 238 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 239 | + $ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service'); |
|
| 240 | 240 | |
| 241 | - $serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 242 | - $ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem ); |
|
| 241 | + $serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 242 | + $ordServItem = $ordServManager->createItem()->copyFrom($serviceItem); |
|
| 243 | 243 | |
| 244 | - $ordBaseItem->addService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
| 244 | + $ordBaseItem->addService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
| 245 | 245 | |
| 246 | 246 | |
| 247 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 248 | - ->setConstructorArgs( [$this->context] ) |
|
| 249 | - ->setMethods( ['addService'] ) |
|
| 247 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 248 | + ->setConstructorArgs([$this->context]) |
|
| 249 | + ->setMethods(['addService']) |
|
| 250 | 250 | ->getMock(); |
| 251 | 251 | |
| 252 | - $object->expects( $this->once() )->method( 'addService' )->will( $this->throwException( new \Exception() ) ); |
|
| 252 | + $object->expects($this->once())->method('addService')->will($this->throwException(new \Exception())); |
|
| 253 | 253 | |
| 254 | - $result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 254 | + $result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 255 | 255 | |
| 256 | - $this->assertEquals( 0, count( $result ) ); |
|
| 256 | + $this->assertEquals(0, count($result)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | |
| 260 | 260 | public function testGetOrderProductAttributes() |
| 261 | 261 | { |
| 262 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 263 | - ->setConstructorArgs( [$this->context] ) |
|
| 264 | - ->setMethods( ['getAttributes'] ) |
|
| 262 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 263 | + ->setConstructorArgs([$this->context]) |
|
| 264 | + ->setMethods(['getAttributes']) |
|
| 265 | 265 | ->getMock(); |
| 266 | 266 | |
| 267 | - $list = [1 => new \Aimeos\MShop\Attribute\Item\Standard( ['attribute.code' => 'special_instructions'] )]; |
|
| 268 | - $object->expects( $this->once() )->method( 'getAttributes' )->will( $this->returnValue( $list ) ); |
|
| 267 | + $list = [1 => new \Aimeos\MShop\Attribute\Item\Standard(['attribute.code' => 'special_instructions'])]; |
|
| 268 | + $object->expects($this->once())->method('getAttributes')->will($this->returnValue($list)); |
|
| 269 | 269 | |
| 270 | 270 | $values = new \stdClass(); // test for PHP bug |
| 271 | 271 | $values->{'1'} = 'test'; |
| 272 | - $result = $this->access( 'getOrderProductAttributes' )->invokeArgs( $object, ['test', ['1'], (array) $values] ); |
|
| 272 | + $result = $this->access('getOrderProductAttributes')->invokeArgs($object, ['test', ['1'], (array) $values]); |
|
| 273 | 273 | |
| 274 | - $this->assertEquals( 1, count( $result ) ); |
|
| 275 | - $this->assertEquals( 'test', $result[0]->getValue() ); |
|
| 274 | + $this->assertEquals(1, count($result)); |
|
| 275 | + $this->assertEquals('test', $result[0]->getValue()); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * @param string $company |
| 281 | 281 | */ |
| 282 | - protected function getAddress( $company ) |
|
| 282 | + protected function getAddress($company) |
|
| 283 | 283 | { |
| 284 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'customer/address' ); |
|
| 284 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'customer/address'); |
|
| 285 | 285 | |
| 286 | 286 | $search = $manager->createSearch(); |
| 287 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
| 288 | - $items = $manager->searchItems( $search ); |
|
| 287 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
| 288 | + $items = $manager->searchItems($search); |
|
| 289 | 289 | |
| 290 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 291 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
| 290 | + if (($item = reset($items)) === false) { |
|
| 291 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $ordAddrManager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base/address' ); |
|
| 295 | - $ordAddrItem = $ordAddrManager->createItem()->copyFrom( $item ); |
|
| 294 | + $ordAddrManager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base/address'); |
|
| 295 | + $ordAddrItem = $ordAddrManager->createItem()->copyFrom($item); |
|
| 296 | 296 | |
| 297 | 297 | return $ordAddrItem; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
| 301 | - protected function access( $name ) |
|
| 301 | + protected function access($name) |
|
| 302 | 302 | { |
| 303 | - $class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Basket\Base' ); |
|
| 304 | - $method = $class->getMethod( $name ); |
|
| 305 | - $method->setAccessible( true ); |
|
| 303 | + $class = new \ReflectionClass('\Aimeos\Controller\Frontend\Basket\Base'); |
|
| 304 | + $method = $class->getMethod($name); |
|
| 305 | + $method->setAccessible(true); |
|
| 306 | 306 | |
| 307 | 307 | return $method; |
| 308 | 308 | } |
@@ -20,54 +20,54 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
| 22 | 22 | |
| 23 | - $this->stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 23 | + $this->stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 24 | 24 | ->disableOriginalConstructor() |
| 25 | 25 | ->getMock(); |
| 26 | 26 | |
| 27 | - $this->object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ) |
|
| 28 | - ->setConstructorArgs( [$this->stub, $this->context] ) |
|
| 27 | + $this->object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Decorator\Base') |
|
| 28 | + ->setConstructorArgs([$this->stub, $this->context]) |
|
| 29 | 29 | ->getMockForAbstractClass(); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | protected function tearDown() |
| 34 | 34 | { |
| 35 | - unset( $this->context, $this->object, $this->stub ); |
|
| 35 | + unset($this->context, $this->object, $this->stub); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | public function testConstructException() |
| 40 | 40 | { |
| 41 | - $stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Iface' )->getMock(); |
|
| 41 | + $stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Iface')->getMock(); |
|
| 42 | 42 | |
| 43 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Exception' ); |
|
| 43 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Exception'); |
|
| 44 | 44 | |
| 45 | - $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ) |
|
| 46 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
| 45 | + $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Decorator\Base') |
|
| 46 | + ->setConstructorArgs([$stub, $this->context]) |
|
| 47 | 47 | ->getMockForAbstractClass(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function testCall() |
| 52 | 52 | { |
| 53 | - $stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 53 | + $stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 54 | 54 | ->disableOriginalConstructor() |
| 55 | - ->setMethods( ['invalid'] ) |
|
| 55 | + ->setMethods(['invalid']) |
|
| 56 | 56 | ->getMock(); |
| 57 | 57 | |
| 58 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ) |
|
| 59 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
| 58 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Decorator\Base') |
|
| 59 | + ->setConstructorArgs([$stub, $this->context]) |
|
| 60 | 60 | ->getMockForAbstractClass(); |
| 61 | 61 | |
| 62 | - $stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) ); |
|
| 62 | + $stub->expects($this->once())->method('invalid')->will($this->returnValue(true)); |
|
| 63 | 63 | |
| 64 | - $this->assertTrue( $object->invalid() ); |
|
| 64 | + $this->assertTrue($object->invalid()); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | public function testClear() |
| 69 | 69 | { |
| 70 | - $this->stub->expects( $this->once() )->method( 'clear' ); |
|
| 70 | + $this->stub->expects($this->once())->method('clear'); |
|
| 71 | 71 | |
| 72 | 72 | $this->object->clear(); |
| 73 | 73 | } |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | public function testGet() |
| 77 | 77 | { |
| 78 | 78 | $context = \TestHelperFrontend::getContext(); |
| 79 | - $order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->createItem(); |
|
| 79 | + $order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->createItem(); |
|
| 80 | 80 | |
| 81 | - $this->stub->expects( $this->once() )->method( 'get' ) |
|
| 82 | - ->will( $this->returnValue( $order ) ); |
|
| 81 | + $this->stub->expects($this->once())->method('get') |
|
| 82 | + ->will($this->returnValue($order)); |
|
| 83 | 83 | |
| 84 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
| 84 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | public function testSave() |
| 89 | 89 | { |
| 90 | - $this->stub->expects( $this->once() )->method( 'save' ); |
|
| 90 | + $this->stub->expects($this->once())->method('save'); |
|
| 91 | 91 | |
| 92 | 92 | $this->object->save(); |
| 93 | 93 | } |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | public function testSetType() |
| 97 | 97 | { |
| 98 | - $this->stub->expects( $this->once() )->method( 'setType' ); |
|
| 98 | + $this->stub->expects($this->once())->method('setType'); |
|
| 99 | 99 | |
| 100 | - $this->object->setType( 'test' ); |
|
| 100 | + $this->object->setType('test'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | public function testStore() |
| 105 | 105 | { |
| 106 | - $this->stub->expects( $this->once() )->method( 'store' ); |
|
| 106 | + $this->stub->expects($this->once())->method('store'); |
|
| 107 | 107 | |
| 108 | 108 | $this->object->store(); |
| 109 | 109 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | public function testLoad() |
| 113 | 113 | { |
| 114 | - $this->stub->expects( $this->once() )->method( 'load' ); |
|
| 114 | + $this->stub->expects($this->once())->method('load'); |
|
| 115 | 115 | |
| 116 | 116 | $this->object->load( -1 ); |
| 117 | 117 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | public function testAddProduct() |
| 121 | 121 | { |
| 122 | - $this->stub->expects( $this->once() )->method( 'addProduct' ); |
|
| 122 | + $this->stub->expects($this->once())->method('addProduct'); |
|
| 123 | 123 | |
| 124 | 124 | $this->object->addProduct( -1 ); |
| 125 | 125 | } |
@@ -127,73 +127,73 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function testDeleteProduct() |
| 129 | 129 | { |
| 130 | - $this->stub->expects( $this->once() )->method( 'deleteProduct' ); |
|
| 130 | + $this->stub->expects($this->once())->method('deleteProduct'); |
|
| 131 | 131 | |
| 132 | - $this->object->deleteProduct( 0 ); |
|
| 132 | + $this->object->deleteProduct(0); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | public function testEditProduct() |
| 137 | 137 | { |
| 138 | - $this->stub->expects( $this->once() )->method( 'editProduct' ); |
|
| 138 | + $this->stub->expects($this->once())->method('editProduct'); |
|
| 139 | 139 | |
| 140 | - $this->object->editProduct( 0, 1 ); |
|
| 140 | + $this->object->editProduct(0, 1); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | public function testAddCoupon() |
| 145 | 145 | { |
| 146 | - $this->stub->expects( $this->once() )->method( 'addCoupon' ); |
|
| 146 | + $this->stub->expects($this->once())->method('addCoupon'); |
|
| 147 | 147 | |
| 148 | - $this->object->addCoupon( 'test' ); |
|
| 148 | + $this->object->addCoupon('test'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | public function testDeleteCoupon() |
| 153 | 153 | { |
| 154 | - $this->stub->expects( $this->once() )->method( 'deleteCoupon' ); |
|
| 154 | + $this->stub->expects($this->once())->method('deleteCoupon'); |
|
| 155 | 155 | |
| 156 | - $this->object->deleteCoupon( 'test' ); |
|
| 156 | + $this->object->deleteCoupon('test'); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | public function testSetAddress() |
| 161 | 161 | { |
| 162 | - $this->stub->expects( $this->once() )->method( 'setAddress' ); |
|
| 162 | + $this->stub->expects($this->once())->method('setAddress'); |
|
| 163 | 163 | |
| 164 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
| 164 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
| 168 | 168 | public function testAddService() |
| 169 | 169 | { |
| 170 | - $this->stub->expects( $this->once() )->method( 'addService' ); |
|
| 170 | + $this->stub->expects($this->once())->method('addService'); |
|
| 171 | 171 | |
| 172 | - $this->object->addService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, -1 ); |
|
| 172 | + $this->object->addService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, -1); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | public function testDeleteService() |
| 177 | 177 | { |
| 178 | - $this->stub->expects( $this->once() )->method( 'deleteService' ); |
|
| 178 | + $this->stub->expects($this->once())->method('deleteService'); |
|
| 179 | 179 | |
| 180 | - $this->object->deleteService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ); |
|
| 180 | + $this->object->deleteService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | public function testGetController() |
| 185 | 185 | { |
| 186 | - $result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
|
| 186 | + $result = $this->access('getController')->invokeArgs($this->object, []); |
|
| 187 | 187 | |
| 188 | - $this->assertSame( $this->stub, $result ); |
|
| 188 | + $this->assertSame($this->stub, $result); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
| 192 | - protected function access( $name ) |
|
| 192 | + protected function access($name) |
|
| 193 | 193 | { |
| 194 | - $class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ); |
|
| 195 | - $method = $class->getMethod( $name ); |
|
| 196 | - $method->setAccessible( true ); |
|
| 194 | + $class = new \ReflectionClass('\Aimeos\Controller\Frontend\Basket\Decorator\Base'); |
|
| 195 | + $method = $class->getMethod($name); |
|
| 196 | + $method->setAccessible(true); |
|
| 197 | 197 | |
| 198 | 198 | return $method; |
| 199 | 199 | } |