public function testProcess() { $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT; $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context); $search = $manager->createSearch(); $search->setSlice(0, 1); $result = $manager->searchItems($search); if (($customerItem = reset($result)) === false) { throw new \RuntimeException('No customer item found'); } $addrItem = $customerItem->getPaymentAddress(); $addrItem->setEmail('*****@*****.**'); $basketCntl = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context); $basketCntl->setAddress($type, $addrItem); $view = \TestHelperHtml::getView(); $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, array('cs_option_account' => 1)); $view->addHelper('param', $helper); $view->orderBasket = $basketCntl->get(); $this->context->setView($view); $this->object->setView($view); $orderBaseStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock(); $customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock(); $orderBaseStub->expects($this->once())->method('saveItem'); $customerStub->expects($this->once())->method('saveItem'); \Aimeos\MShop\Factory::injectManager($this->context, 'customer', $customerStub); \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $orderBaseStub); $this->object->process(); }
public function testSave() { $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); $propManager = \Aimeos\MShop\Factory::createManager($this->context, 'product/property'); $typeManager = \Aimeos\MShop\Factory::createManager($this->context, 'product/property/type'); $item = $manager->findItem('CNC'); $item->setCode('jqadm-test-property'); $item->setId(null); $manager->saveItem($item); $typeid = $typeManager->findItem('package-height', array(), 'product')->getId(); $param = array('characteristic' => array('property' => array('product.property.id' => array(''), 'product.property.typeid' => array($typeid), 'product.property.value' => array('10.0')))); $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param); $this->view->addHelper('param', $helper); $this->view->item = $item; $result = $this->object->save(); $search = $propManager->createSearch(); $search->setConditions($search->compare('==', 'product.property.parentid', $item->getId())); $items = $propManager->searchItems($search); $manager->deleteItem($item->getId()); $this->assertNull($this->view->get('errors')); $this->assertNull($result); $this->assertEquals(1, count($items)); $this->assertEquals(null, reset($items)->getLanguageId()); $this->assertEquals('10.0', reset($items)->getValue()); }
/** * Receives a notification from a publisher object * * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface * @param string $action Name of the action to listen for * @param mixed $value Object or value changed in publisher */ public function update(\Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null) { if (!$order instanceof \Aimeos\MShop\Order\Item\Base\Iface) { $msg = $this->getContext()->getI18n()->dt('mshop', 'Object is not of required type "%1$s"'); throw new \Aimeos\MShop\Plugin\Exception(sprintf($msg, '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface')); } $notAvailable = array(); if (self::$lock === false) { self::$lock = true; $couponManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); foreach ($order->getCoupons() as $code => $products) { $search = $couponManager->createSearch(true); $expr = array($search->compare('==', 'coupon.code.code', $code), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $search->setSlice(0, 1); $results = $couponManager->searchItems($search); if (($couponItem = reset($results)) !== false) { $couponProvider = $couponManager->getProvider($couponItem, $code); $couponProvider->updateCoupon($order); } else { $notAvailable[$code] = 'coupon.gone'; } } self::$lock = false; } if (count($notAvailable) > 0) { $codes = array('coupon' => $notAvailable); $msg = $this->getContext()->getI18n()->dt('mshop', 'Coupon in basket is not available any more'); throw new \Aimeos\MShop\Plugin\Provider\Exception($msg, -1, null, $codes); } return true; }
public function testSave() { $typeManager = \Aimeos\MShop\Factory::createManager($this->context, 'text/type'); $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); $item = $manager->findItem('CNC'); $item->setCode('jqadm-test'); $item->setId(null); $manager->saveItem($item); $param = array('text' => array('langid' => array('de'), 'name' => array('listid' => '', 'content' => 'test name'), 'short' => array('listid' => '', 'content' => 'short desc'), 'long' => array('listid' => '', 'content' => 'long desc'), 'url' => array('listid' => '', 'content' => 'url segment'), 'meta-keyword' => array('listid' => '', 'content' => 'meta keywords'), 'meta-description' => array('listid' => '', 'content' => 'meta desc'))); $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param); $this->view->addHelper('param', $helper); $this->view->item = $item; $result = $this->object->save(); $item = $manager->getItem($item->getId(), array('text')); $manager->deleteItem($item->getId()); $this->assertNull($this->view->get('errors')); $this->assertNull($result); $this->assertEquals(6, count($item->getListItems())); foreach ($item->getListItems('text') as $listItem) { $this->assertEquals('text', $listItem->getDomain()); $this->assertEquals('default', $listItem->getType()); $refItem = $listItem->getRefItem(); $this->assertEquals('de', $refItem->getLanguageId()); } }
/** * Returns the manager the controller is using. * * @return \Aimeos\MShop\Common\Manager\Iface Manager object */ protected function getManager() { if ($this->manager === null) { $this->manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'supplier/address'); } return $this->manager; }
public function testSave() { $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); $item = $manager->findItem('CNE'); $item->setCode('jqadm-test-download'); $item->setId(null); $manager->saveItem($item); $param = array('download' => array('product.lists.id' => '', 'product.lists.status' => '1', 'attribute.label' => 'test')); $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param); $this->view->addHelper('param', $helper); $file = $this->getMockBuilder('\\Psr\\Http\\Message\\UploadedFileInterface')->getMock(); $file->expects($this->any())->method('getError')->will($this->returnValue(UPLOAD_ERR_OK)); $request = $this->getMockBuilder('\\Psr\\Http\\Message\\ServerRequestInterface')->getMock(); $request->expects($this->any())->method('getUploadedFiles')->will($this->returnValue(array('download' => array('file' => $file)))); $helper = new \Aimeos\MW\View\Helper\Request\Standard($this->view, $request); $this->view->addHelper('request', $helper); $this->view->item = $item; $this->object->expects($this->once())->method('storeFile')->will($this->returnValue('test/file.ext')); $attributeStub = $this->getMockBuilder('\\Aimeos\\MShop\\Attribute\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock(); $attributeStub->expects($this->once())->method('saveItem'); \Aimeos\MShop\Factory::injectManager($this->context, 'attribute', $attributeStub); \Aimeos\MShop\Factory::setCache(true); $result = $this->object->save(); \Aimeos\MShop\Factory::setCache(false); $item = $manager->getItem($item->getId(), array('attribute')); $manager->deleteItem($item->getId()); $this->assertNull($this->view->get('errors')); $this->assertNull($result); $this->assertEquals(1, count($item->getListItems('attribute', 'hidden'))); }
/** * Returns the manager the controller is using. * * @return \Aimeos\MShop\Common\Manager\Iface Manager object */ protected function getManager() { if ($this->manager === null) { $this->manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/service/attribute'); } return $this->manager; }
/** * Returns the manager the controller is using. * * @return \Aimeos\MShop\Common\Manager\Iface Manager object */ protected function getManager() { if ($this->manager === null) { $this->manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/group'); } return $this->manager; }
public function testSave() { $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); $item = $manager->findItem('CNC'); $item->setCode('jqadm-test-image'); $item->setId(null); $manager->saveItem($item); $param = array('image' => array('product.lists.id' => array(''), 'media.languageid' => array('de'), 'media.label' => array('test'))); $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param); $this->view->addHelper('param', $helper); $files = array('image' => array('files' => array(array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => 0)))); $helper = $this->getMockBuilder('\\Aimeos\\MW\\View\\Helper\\Request\\Standard')->setConstructorArgs(array($this->view, '', '', null, $files))->setMethods(array('checkUploadedFile'))->getMock(); $this->view->addHelper('request', $helper); $this->view->item = $item; $name = 'AdminJQAdmProductImageSave'; $this->context->getConfig()->set('controller/common/media/name', $name); $cntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Media\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('add'))->getMock(); \Aimeos\Controller\Common\Media\Factory::injectController('\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub); $cntlStub->expects($this->once())->method('add'); $mediaStub = $this->getMockBuilder('\\Aimeos\\MShop\\Media\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock(); \Aimeos\MShop\Factory::injectManager($this->context, 'media', $mediaStub); $mediaStub->expects($this->once())->method('saveItem'); \Aimeos\MShop\Factory::setCache(true); $result = $this->object->save(); \Aimeos\MShop\Factory::setCache(false); $item = $manager->getItem($item->getId(), array('media')); $manager->deleteItem($item->getId()); $this->assertNull($this->view->get('errors')); $this->assertNull($result); $this->assertEquals(1, count($item->getListItems('media'))); }
/** * Receives a notification from a publisher object * * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface * @param string $action Name of the action to listen for * @param mixed $value Object or value changed in publisher * @throws \Aimeos\MShop\Plugin\Exception in case of faulty configuration or parameters * @return bool true if attributes have been added successfully */ public function update(\Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null) { if (!$order instanceof \Aimeos\MShop\Order\Item\Base\Iface) { $msg = $this->getContext()->getI18n()->dt('mshop', 'Object is not of required type "%1$s"'); throw new \Aimeos\MShop\Plugin\Exception(sprintf($msg, '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface')); } if (!$value instanceof \Aimeos\MShop\Order\Item\Base\Product\Iface) { $msg = $this->getContext()->getI18n()->dt('mshop', 'Object is not of required type "%1$s"'); throw new \Aimeos\MShop\Plugin\Exception(sprintf($msg, '\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Iface')); } $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); $config = $this->getItemBase()->getConfig(); foreach ($config as $key => $properties) { $keyElements = explode('.', $key); if ($keyElements[0] !== 'product' || count($keyElements) < 3) { $msg = $this->getContext()->getI18n()->dt('mshop', 'Configuration invalid'); throw new \Aimeos\MShop\Plugin\Exception($msg); } $productSubManager = $productManager->getSubManager($keyElements[1]); $search = $productSubManager->createSearch(true); $cond = array(); $cond[] = $search->compare('==', $key, $value->getProductId()); $cond[] = $search->getConditions(); $search->setConditions($search->combine('&&', $cond)); $result = $productSubManager->searchItems($search); foreach ($result as $item) { $attributes = $this->addAttributes($item, $value, $properties); $value->setAttributes($attributes); } } return true; }
public function testSave() { $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); $item = $manager->findItem('U:TEST'); $item->setCode('jqadm-test-selection'); $item->setId(null); $manager->saveItem($item); $attrManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); $attrItem = $attrManager->findItem('xs', array(), 'product', 'size'); $param = array('selection' => array('product.lists.id' => array(0 => ''), 'product.id' => array(0 => $item->getId()), 'product.code' => array(0 => 'testprod'), 'product.label' => array(0 => 'test product'), 'attr' => array('id' => array(0 => $attrItem->getId()), 'label' => array(0 => 'test attribute'), 'ref' => array(0 => 'testprod')))); $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param); $this->view->addHelper('param', $helper); $this->view->item = $item; $result = $this->object->save(); $item = $manager->getItem($item->getId(), array('product')); $variants = $item->getListItems('product', 'default'); if (empty($variants)) { throw new \Exception('No variant products available'); } $variant = $manager->getItem(reset($variants)->getRefId(), array('attribute')); $attributes = $variant->getListItems('attribute', 'variant'); $manager->deleteItems(array($item->getId(), $variant->getId())); $this->assertNull($this->view->get('errors')); $this->assertNull($result); $this->assertEquals(1, count($variants)); $this->assertEquals(1, count($attributes)); $this->assertEquals('testprod', $variant->getCode()); $this->assertEquals($attrItem->getId(), reset($attributes)->getRefId()); }
public function testGetBody() { $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); $this->context->setUserId($manager->findItem('UTC001')->getId()); $output = $this->object->getBody(); $this->assertStringStartsWith('<section class="aimeos account-profile">', $output); }
/** * Receives a notification from a publisher object * * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface * @param string $action Name of the action to listen for * @param mixed $value Object or value changed in publisher * @throws \Aimeos\MShop\Plugin\Provider\Exception if checks fail * @return bool true if checks succeed */ public function update(\Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null) { $class = '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface'; if (!$order instanceof $class) { throw new \Aimeos\MShop\Plugin\Exception(sprintf('Object is not of required type "%1$s"', $class)); } $class = '\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Iface'; if (!$value instanceof $class) { throw new \Aimeos\MShop\Plugin\Exception(sprintf('Object is not of required type "%1$s"', $class)); } $config = $this->getItemBase()->getConfig(); if ($config === array()) { return true; } $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); $criteria = $productManager->createSearch(true); $expr = array(); $expr[] = $criteria->compare('==', 'product.id', $value->getProductId()); $expr[] = $criteria->getConditions(); foreach ($config as $property => $value) { $expr[] = $criteria->compare('==', $property, $value); } $criteria->setConditions($criteria->combine('&&', $expr)); $result = $productManager->searchItems($criteria); if (reset($result) === false) { $code = array('product' => array_keys($config)); throw new \Aimeos\MShop\Plugin\Provider\Exception(sprintf('Product matching given properties not found'), -1, null, $code); } return true; }
/** * Checks if the the basket weight is ok for the service provider. * * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object * @return boolean True if payment provider can be used, false if not */ public function isAvailable(\Aimeos\MShop\Order\Item\Base\Iface $basket) { $context = $this->getContext(); $prodMap = array(); $basketWeight = 0; foreach ($basket->getProducts() as $basketItem) { $prodId = $basketItem->getProductId(); // basket can contain a product several times in different basket items if (!isset($prodMap[$prodId])) { $prodMap[$prodId] = 0.0; } $prodMap[$prodId] += $basketItem->getQuantity(); } $propertyManager = \Aimeos\MShop\Factory::createManager($context, 'product/property'); $search = $propertyManager->createSearch(true); $expr = array($search->compare('==', 'product.property.parentid', array_keys($prodMap)), $search->compare('==', 'product.property.type.code', 'package-weight'), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $search->setSlice(0, 0x7fffffff); // if more than 100 products are in the basket foreach ($propertyManager->searchItems($search) as $property) { $basketWeight += (double) $property->getValue() * $prodMap[$property->getParentId()]; } if ($this->checkWeightScale($basketWeight) === false) { return false; } return $this->getProvider()->isAvailable($basket); }
protected function update(array $list) { $map = array(); $manager = \Aimeos\MShop\Factory::createManager($this->additional, 'product/property'); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'product.property.code', array_keys($list))); $search->setSlice(0, count($list)); foreach ($manager->searchItems($search) as $id => $item) { $map[$item->getCode()] = $item; } $manager->begin(); foreach ($list as $code => $entry) { if (!isset($map[$code])) { $item = $manager->createItem(); } else { $item = $map[$code]; } $item->setParentId('...'); $item->setValue($entry['value']); $item->setStatus(!(bool) $entry['hidden']); $item->setTypeId($this->getTypeId('product/property/type', 'product', $entry['title'])); $manager->saveItem($item); } $manager->commit(); }
public function testSaveItemLabelContent() { $typeManager = \Aimeos\MShop\Factory::createManager(\TestHelperExtjs::getContext(), 'text/type'); $criteria = $typeManager->createSearch(); $criteria->setSlice(0, 1); $result = $typeManager->searchItems($criteria); if (($type = reset($result)) === false) { throw new \Exception('No type item found'); } $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('text.content' => 'controller test text', 'text.domain' => 'product', 'text.typeid' => $type->getId(), 'text.languageid' => 'de', 'text.status' => 1)); $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('text.content' => 'controller test text'))))); $saved = $this->object->saveItems($saveParams); $searched = $this->object->searchItems($searchParams); $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'text.id'}); $this->object->deleteItems($deleteParams); $result = $this->object->searchItems($searchParams); $this->assertInternalType('object', $saved['items']); $this->assertNotNull($saved['items']->{'text.id'}); $this->assertEquals($saved['items']->{'text.id'}, $searched['items'][0]->{'text.id'}); $this->assertEquals($saved['items']->{'text.content'}, $searched['items'][0]->{'text.content'}); $this->assertEquals($saved['items']->{'text.domain'}, $searched['items'][0]->{'text.domain'}); $this->assertEquals($saved['items']->{'text.typeid'}, $searched['items'][0]->{'text.typeid'}); $this->assertEquals($saved['items']->{'text.content'}, $searched['items'][0]->{'text.label'}); $this->assertEquals($saved['items']->{'text.languageid'}, $searched['items'][0]->{'text.languageid'}); $this->assertEquals($saved['items']->{'text.status'}, $searched['items'][0]->{'text.status'}); $this->assertEquals(1, count($searched['items'])); $this->assertEquals(0, count($result['items'])); $this->assertEquals('controller test text', $saved['items']->{'text.label'}); }
public function testSave() { $typeManager = \Aimeos\MShop\Factory::createManager($this->context, 'price/type'); $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); $item = $manager->findItem('CNC'); $item->setCode('jqadm-test'); $item->setId(null); $manager->saveItem($item); $param = array('price' => array('product.lists.id' => array(''), 'price.typeid' => array($typeManager->findItem('default', array(), 'product')->getId()), 'price.currencyid' => array('EUR'), 'price.label' => array('test'), 'price.quantity' => array('2'), 'price.value' => array('10.00'), 'price.costs' => array('1.00'), 'price.rebate' => array('5.00'), 'price.taxrate' => array('20.00'))); $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param); $this->view->addHelper('param', $helper); $this->view->item = $item; $result = $this->object->save(); $item = $manager->getItem($item->getId(), array('price')); $manager->deleteItem($item->getId()); $this->assertNull($this->view->get('errors')); $this->assertNull($result); $this->assertEquals(1, count($item->getListItems())); foreach ($item->getListItems('price') as $listItem) { $this->assertEquals('price', $listItem->getDomain()); $this->assertEquals('default', $listItem->getType()); $refItem = $listItem->getRefItem(); $this->assertEquals('default', $refItem->getType()); $this->assertEquals('EUR', $refItem->getCurrencyId()); $this->assertEquals('test', $refItem->getLabel()); $this->assertEquals('2', $refItem->getQuantity()); $this->assertEquals('10.00', $refItem->getValue()); $this->assertEquals('1.00', $refItem->getCosts()); $this->assertEquals('5.00', $refItem->getRebate()); $this->assertEquals('20.00', $refItem->getTaxRate()); } }
/** * Returns the manager the controller is using. * * @return \Aimeos\MShop\Common\Manager\Iface Manager object */ protected function getManager() { if ($this->manager === null) { $this->manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute/type'); } return $this->manager; }
/** * Returns the manager the controller is using. * * @return \Aimeos\MShop\Common\Manager\Iface Manager object */ protected function getManager() { if ($this->manager === null) { $this->manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service/lists'); } return $this->manager; }
public static function bootstrap() { set_error_handler('TestHelperExtjs::errorHandler'); self::getAimeos(); \Aimeos\MShop\Factory::setCache(false); \Aimeos\Controller\ExtJS\Factory::setCache(false); }
/** * Returns the manager the controller is using. * * @return \Aimeos\MShop\Common\Manager\Iface Manager object */ protected function getManager() { if ($this->manager === null) { $this->manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); } return $this->manager; }
public function testProcess() { $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT; $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context); $search = $manager->createSearch(); $search->setSlice(0, 1); $result = $manager->searchItems($search); if (($customerItem = reset($result)) === false) { throw new \Exception('No customer item found'); } $addrItem = $customerItem->getPaymentAddress(); $addrItem->setEmail('*****@*****.**'); $mailStub = $this->getMockBuilder('\\Aimeos\\MW\\Mail\\None')->disableOriginalConstructor()->getMock(); $mailMsgStub = $this->getMockBuilder('\\Aimeos\\MW\\Mail\\Message\\None')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $mailStub->expects($this->once())->method('createMessage')->will($this->returnValue($mailMsgStub)); $mailStub->expects($this->once())->method('send'); $this->context->setMail($mailStub); $basketCntl = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context); $basketCntl->setAddress($type, $addrItem); $view = \TestHelperHtml::getView(); $view->orderBasket = $basketCntl->get(); $this->context->setView($view); $this->object->setView($view); $orderBaseStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock(); $customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock(); $orderBaseStub->expects($this->once())->method('saveItem'); $customerStub->expects($this->once())->method('saveItem'); \Aimeos\MShop\Factory::injectManager($this->context, 'customer', $customerStub); \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $orderBaseStub); $this->object->process(); }
public function testAddProductNoCategory() { $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); $item = $manager->findItem('ABCD'); $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); $this->object->addProduct($item->getId(), 5); }
/** * Checks if payment provider can be used based on the basket content. * Checks for country, currency, address, scoring, etc. should be implemented in separate decorators * * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object * @return boolean True if payment provider can be used, false if not */ public function isAvailable(\Aimeos\MShop\Order\Item\Base\Iface $basket) { $context = $this->getContext(); $config = $this->getServiceItem()->getConfig(); if (($customerId = $context->getUserId()) === null) { return false; } $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); if (isset($config['ordercheck.total-number-min'])) { $search = $manager->createSearch(true); $expr = array($search->compare('==', 'order.base.customerid', $customerId), $search->compare('>=', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $search->setSlice(0, $config['ordercheck.total-number-min']); $result = $manager->searchItems($search); if (count($result) < (int) $config['ordercheck.total-number-min']) { return false; } } if (isset($config['ordercheck.limit-days-pending'])) { $time = time() - (int) $config['ordercheck.limit-days-pending'] * 86400; $search = $manager->createSearch(true); $expr = array($search->compare('==', 'order.base.customerid', $customerId), $search->compare('==', 'order.datepayment', date('Y-m-d H:i:s', $time)), $search->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $search->setSlice(0, 1); $result = $manager->searchItems($search); if (count($result) > 0) { return false; } } return $this->getProvider()->isAvailable($basket); }
/** * Returns the product properties for the given product ID * * @param string $prodid Unique product ID * @return array Associative list of product stock items */ protected function getStockItems($prodid) { $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'product.stock.productid', $prodid)); return $manager->searchItems($search); }
protected function update(array $list) { $pos = 0; $map = array(); $manager = \Aimeos\MShop\Factory::createManager($this->additional, 'attribute'); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'attribute.code', array_keys($list))); $search->setSlice(0, count($list)); foreach ($manager->searchItems($search) as $id => $item) { $map[$item->getCode()] = $item; } $manager->begin(); foreach ($list as $code => $entry) { if (!isset($map[$code])) { $item = $manager->createItem(); } else { $item = $map[$code]; } $typeid = $this->getTypeId('attribute/type', 'product', $entry['title']); $item->setTypeId($typeid); $item->setDomain('product'); $item->setCode($entry['value']); $item->setLabel($entry['value']); $item->setStatus(!(bool) $entry['hidden']); $item->setPosition($pos++); $manager->saveItem($item); } $manager->commit(); }
/** * Returns the list items for association relationships * * @param array $items List of items implementing \Aimeos\MShop\Common\Item\Iface * @param array $include List of resource types that should be fetched * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface */ protected function getListItems(array $items, array $include) { $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'supplier/lists'); $search = $manager->createSearch(); $expr = array($search->compare('==', 'supplier.lists.parentid', array_keys($items)), $search->compare('==', 'supplier.lists.domain', $include)); $search->setConditions($search->combine('&&', $expr)); return $manager->searchItems($search); }
public function testRun() { $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('deleteItems', 'saveItem'))->getMock(); \Aimeos\MShop\Factory::injectManager($this->context, 'product/lists', $stub); $stub->expects($this->atLeastOnce())->method('deleteItems'); $stub->expects($this->atLeastOnce())->method('saveItem'); $this->object->run(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $context = \TestHelperMShop::getContext(); $this->ordServItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/service')->createItem(); $serviceItem = \Aimeos\MShop\Factory::createManager($context, 'service')->createItem(); $serviceItem->setCode('test'); $this->object = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Payment\\DirectDebit')->setMethods(array('getOrder', 'getOrderBase', 'saveOrder', 'saveOrderBase'))->setConstructorArgs(array($context, $serviceItem))->getMock(); }
public function testSet() { $item = \Aimeos\MShop\Factory::createManager(\TestHelperCntl::getContext(), 'product/stock/warehouse')->createItem(); $item->setCode('cache-test'); $item->setId(1); $this->object->set($item); $id = $this->object->get('cache-test'); $this->assertEquals($item->getId(), $id); }