Exemplo n.º 1
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->editor = \TestHelper::getContext()->getEditor();
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelper::getContext(), 'Typo3');
     $listManager = $manager->getSubManager('lists', 'Typo3');
     $this->object = $listManager->getSubManager('type', 'Typo3');
 }
Exemplo n.º 2
0
 public function testProcess()
 {
     $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY;
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $addrManager = $manager->getSubManager('address');
     $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->setId(null);
     $basketCntl = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $basketCntl->setAddress($type, $addrItem);
     $view = \TestHelperHtml::getView();
     $view->orderBasket = $basketCntl->get();
     $view->orderBasket->setCustomerId($customerItem->getId());
     $this->object->setView($view);
     $this->object->process();
     $orderAddress = $view->orderBasket->getAddress($type);
     $actual = $addrManager->getItem($orderAddress->getAddressId());
     $addrManager->deleteItem($actual->getId());
     $this->assertEquals($addrItem->getFirstname(), $actual->getFirstname());
     $this->assertEquals($addrItem->getLastname(), $actual->getLastname());
     $this->assertEquals($addrItem->getPostal(), $actual->getPostal());
     $this->assertEquals($addrItem->getTelephone(), $actual->getTelephone());
     $this->assertEquals($addrItem->getTelefax(), $actual->getTelefax());
 }
Exemplo n.º 3
0
 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();
 }
 /**
  * Adds attribute test data.
  */
 public function migrate()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding Fos user bundle customer test data', 0);
     $parentIds = array();
     $ds = DIRECTORY_SEPARATOR;
     $this->additional->setEditor('ai-fosuser:unittest');
     $path = __DIR__ . $ds . 'data' . $ds . 'customer.php';
     if (($testdata = (include $path)) === false) {
         throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for customer domain', $path));
     }
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->additional, 'FosUser');
     $customerAddressManager = $customerManager->getSubManager('address', 'FosUser');
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', array('UTC001', 'UTC002', 'UTC003')));
     $items = $customerManager->searchItems($search);
     $this->conn->begin();
     $customerManager->deleteItems(array_keys($items));
     $parentIds = $this->addCustomerData($testdata, $customerManager, $customerAddressManager->createItem());
     $this->addCustomerAddressData($testdata, $customerAddressManager, $parentIds);
     $this->conn->commit();
     $this->status('done');
 }
Exemplo n.º 5
0
 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();
 }
 /**
  * Inserts customer items.
  */
 public function migrate()
 {
     $this->msg('Adding customer performance data', 0);
     $context = $this->getContext();
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context);
     $customerItem = $customerManager->createItem();
     $customerItem->setCode('demo-test');
     $customerItem->setLabel('Test demo unitperf user');
     $customerItem->setPassword(sha1(microtime(true) . getmypid() . rand()));
     $customerItem->setStatus(1);
     $addrItem = $customerItem->getPaymentAddress();
     $addrItem->setCompany('Test company');
     $addrItem->setVatID('DE999999999');
     $addrItem->setSalutation('mr');
     $addrItem->setFirstname('Testdemo');
     $addrItem->setLastname('Perfuser');
     $addrItem->setAddress1('Test street');
     $addrItem->setAddress2('1');
     $addrItem->setPostal('1000');
     $addrItem->setCity('Test city');
     $addrItem->setLanguageId('en');
     $addrItem->setCountryId('DE');
     $addrItem->setEmail('me@localhost');
     $customerManager->saveItem($customerItem);
     $this->status('done');
 }
Exemplo n.º 7
0
 public static function setUpBeforeClass()
 {
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperHtml::getContext());
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', 'UTC001'));
     $result = $manager->searchItems($search);
     if ((self::$customerItem = reset($result)) === false) {
         throw new \Exception('No customer found');
     }
 }
Exemplo n.º 8
0
 /**
  * @param string $code
  */
 protected function getCustomerItem($code)
 {
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', $code));
     $items = $manager->searchItems($search);
     if (($item = reset($items)) === false) {
         throw new \RuntimeException(sprintf('No customer item with code "%1$s" found', $code));
     }
     return $item;
 }
Exemplo n.º 9
0
 protected function getBasket()
 {
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', 'UTC001'));
     $result = $customerManager->searchItems($search);
     if (($customer = reset($result)) === false) {
         throw new \Exception('Customer item not found');
     }
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $controller->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $customer->getPaymentAddress());
     $controller->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $customer->getPaymentAddress());
     return $controller->get();
 }
Exemplo n.º 10
0
 /**
  * Gets required customer item ids.
  *
  * @param array $keys List with referenced Ids
  * @return array $refIds List with referenced Ids
  * @throws \Aimeos\MW\Setup\Exception If no type ID is found
  */
 private function getCustomerData(array $keys)
 {
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->additional, 'Standard');
     $codes = array();
     foreach ($keys as $dataset) {
         if (($pos = strpos($dataset, '/')) === false || ($str = substr($dataset, $pos + 1)) === false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('Some keys for ref customer are set wrong "%1$s"', $dataset));
         }
         $codes[] = $str;
     }
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', $codes));
     $refIds = array();
     foreach ($customerManager->searchItems($search) as $item) {
         $refIds['customer/' . $item->getCode()] = $item->getId();
     }
     return $refIds;
 }
Exemplo n.º 11
0
 /**
  * Adds the customer data
  *
  * @param string $path Path to data file
  * @throws \Aimeos\MShop\Exception
  */
 protected function process($path)
 {
     if (($testdata = (include $path)) == false) {
         throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for customer domain', $path));
     }
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->additional, 'Standard');
     $customerAddressManager = $customerManager->getSubManager('address', 'Standard');
     $customerGroupManager = $customerManager->getSubManager('group', 'Standard');
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('=~', 'customer.code', 'UTC00'));
     $items = $customerManager->searchItems($search);
     $this->conn->begin();
     $customerManager->deleteItems(array_keys($items));
     $parentIds = $this->addCustomerData($testdata, $customerManager, $customerAddressManager->createItem());
     $this->addCustomerAddressData($testdata, $customerAddressManager, $parentIds);
     $this->addCustomerGroupData($testdata, $customerGroupManager);
     $this->conn->commit();
 }
Exemplo n.º 12
0
 public static function setUpBeforeClass()
 {
     $context = \TestHelper::getContext();
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context);
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', 'UTC001'));
     $result = $manager->searchItems($search);
     if ((self::$customerItem = reset($result)) === false) {
         throw new \Exception('No customer found');
     }
     $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($context);
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'product.code', array('CNC', 'CNE')));
     foreach ($manager->searchItems($search, array('text', 'price', 'media')) as $id => $product) {
         $prices = $product->getRefItems('price', 'default', 'default');
         self::$productItems[$id]['price'] = reset($prices);
         self::$productItems[$id]['item'] = $product;
     }
 }
 /**
  * Adds attribute test data.
  */
 public function migrate()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding Laravel customer test data', 0);
     $this->additional->setEditor('ai-laravel:unittest');
     $parentIds = array();
     $ds = DIRECTORY_SEPARATOR;
     $path = __DIR__ . $ds . 'data' . $ds . 'customer.php';
     if (($testdata = (include $path)) == false) {
         throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for customer domain', $path));
     }
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->additional, 'Laravel');
     $customerAddressManager = $customerManager->getSubManager('address', 'Laravel');
     $this->cleanupCustomerData($customerManager, $customerAddressManager);
     $this->conn->begin();
     $parentIds = $this->addCustomerData($testdata, $customerManager, $customerAddressManager->createItem());
     $this->addCustomerAddressData($testdata, $customerAddressManager, $parentIds);
     $this->conn->commit();
     $this->status('done');
 }
Exemplo n.º 14
0
 /**
  * Adds attribute test data.
  */
 protected function mysql()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding TYPO3 customer test data', 0);
     $this->additional->setEditor('ai-typo3:unittest');
     $parentIds = array();
     $ds = DIRECTORY_SEPARATOR;
     $path = __DIR__ . $ds . 'data' . $ds . 'customer.php';
     if (($testdata = (include $path)) == false) {
         throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for customer domain', $path));
     }
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->additional, 'Typo3');
     $customerAddressManager = $customerManager->getSubManager('address', 'Typo3');
     foreach ($customerManager->searchItems($customerManager->createSearch()) as $id => $item) {
         $parentIds['customer/' . $item->getCode()] = $id;
     }
     $this->conn->begin();
     $this->addCustomerAddressData($testdata, $customerAddressManager, $parentIds);
     $this->conn->commit();
     $this->status('done');
 }
Exemplo n.º 15
0
 public function testUpdateAddress()
 {
     $context = \TestHelperMShop::getContext();
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context);
     $context->setUserId($customerManager->findItem('UTC001')->getId());
     $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
     $this->plugin->setConfig(array('autofill.address' => '1'));
     $object = new \Aimeos\MShop\Plugin\Provider\Order\Autofill($context, $this->plugin);
     $this->assertTrue($object->update($this->order, 'addProduct.after'));
     $this->assertEquals(array(), $this->order->getServices());
     $this->assertEquals(1, count($this->order->getAddresses()));
     $this->assertInstanceOf('\\Aimeos\\MShop\\Order\\Item\\Base\\Address\\Iface', $this->order->getAddress($type));
 }
Exemplo n.º 16
0
 protected function getBasket()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $customer = $customerManager->findItem('UTC001');
     $controller->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $customer->getPaymentAddress());
     $controller->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $customer->getPaymentAddress());
     $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
     $product = $productManager->findItem('CNE');
     $controller->addProduct($product->getId(), 2, array(), array(), array(), array(), array(), 'default');
     $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager($this->context);
     $service = $serviceManager->findItem('unitpaymentcode', array(), 'service', 'payment');
     $controller->setService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, $service->getId());
     $service = $serviceManager->findItem('unitcode', array(), 'service', 'delivery');
     $controller->setService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY, $service->getId());
     return $controller->get();
 }
Exemplo n.º 17
0
 /**
  * Returns the customer group item for the given code
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
  * @param string $code Unique customer group code
  * @return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object
  */
 protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code)
 {
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group');
     try {
         $item = $manager->findItem($code);
     } catch (\Aimeos\MShop\Exception $e) {
         $item = $manager->createItem();
         $item->setLabel($code);
         $item->setCode($code);
         $manager->saveItem($item);
     }
     return $item;
 }
Exemplo n.º 18
0
 /**
  * Adds the customer-list test data.
  *
  * @param array $testdata Associative list of key/list pairs
  * @param array $refIds Associative list of domains and the keys/IDs of the inserted items
  * @param string $type Manager type string
  * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
  */
 protected function addCustomerListData(array $testdata, array $refIds, $type = 'Standard')
 {
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->additional, $type);
     $customerListManager = $customerManager->getSubManager('lists', $type);
     $customerListTypeManager = $customerListManager->getSubmanager('type', $type);
     $itemCode = array();
     foreach ($testdata['customer/lists'] as $dataset) {
         if (($pos = strpos($dataset['parentid'], '/')) === false || ($str = substr($dataset['parentid'], $pos + 1)) === false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('Some keys for parentid are set wrong "%1$s"', $dataset['parentid']));
         }
         $itemCode[] = $str;
     }
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', $itemCode));
     $parentIds = array();
     foreach ($customerManager->searchItems($search) as $item) {
         $parentIds['customer/' . $item->getCode()] = $item->getId();
     }
     $listItemTypeIds = array();
     $listItemType = $customerListTypeManager->createItem();
     $this->conn->begin();
     foreach ($testdata['customer/lists/type'] as $key => $dataset) {
         $listItemType->setId(null);
         $listItemType->setCode($dataset['code']);
         $listItemType->setDomain($dataset['domain']);
         $listItemType->setLabel($dataset['label']);
         $listItemType->setStatus($dataset['status']);
         $customerListTypeManager->saveItem($listItemType);
         $listItemTypeIds[$key] = $listItemType->getId();
     }
     $listItem = $customerListManager->createItem();
     foreach ($testdata['customer/lists'] as $dataset) {
         if (!isset($parentIds[$dataset['parentid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No customer ID found for "%1$s"', $dataset['parentid']));
         }
         if (!isset($refIds[$dataset['domain']][$dataset['refid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No "%2$s" ref ID found for "%1$s"', $dataset['refid'], $dataset['domain']));
         }
         if (!isset($listItemTypeIds[$dataset['typeid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No customer list type ID found for "%1$s"', $dataset['typeid']));
         }
         $listItem->setId(null);
         $listItem->setParentId($parentIds[$dataset['parentid']]);
         $listItem->setTypeId($listItemTypeIds[$dataset['typeid']]);
         $listItem->setRefId($refIds[$dataset['domain']][$dataset['refid']]);
         $listItem->setDomain($dataset['domain']);
         $listItem->setDateStart($dataset['start']);
         $listItem->setDateEnd($dataset['end']);
         $listItem->setConfig($dataset['config']);
         $listItem->setPosition($dataset['pos']);
         $listItem->setStatus($dataset['status']);
         $customerListManager->saveItem($listItem, false);
     }
     $this->conn->commit();
 }
Exemplo n.º 19
0
 /**
  * @param string $company
  */
 protected function getAddress($company)
 {
     $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelper::getContext(), 'Standard');
     $addressManager = $customer->getSubManager('address', 'Standard');
     $search = $addressManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.address.company', $company));
     $items = $addressManager->searchItems($search);
     if (($item = reset($items)) === false) {
         throw new \Exception(sprintf('No address item with company "%1$s" found', $company));
     }
     return $item;
 }
Exemplo n.º 20
0
 public function testProcessExistingAddress()
 {
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', 'UTC001'));
     $result = $customerManager->searchItems($search);
     if (($customer = reset($result)) === false) {
         throw new \Exception('Customer item not found');
     }
     $customerAddressManager = $customerManager->getSubManager('address');
     $search = $customerAddressManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.address.parentid', $customer->getId()));
     $result = $customerAddressManager->searchItems($search);
     if (($address = reset($result)) === false) {
         throw new \Exception('Customer address item not found');
     }
     $this->context->setUserId($customer->getId());
     $view = \TestHelperHtml::getView();
     $param = array('ca_deliveryoption' => $address->getId());
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $param);
     $view->addHelper('param', $helper);
     $this->object->setView($view);
     $this->object->process();
     $this->context->setEditor(null);
     $basket = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context)->get();
     $this->assertEquals('Example company', $basket->getAddress('delivery')->getCompany());
 }
Exemplo n.º 21
0
 /**
  * Returns the customer IDs for the given test data.
  *
  * @param array $testdata Test data
  * @return array Customer Ids
  */
 protected function getCustomerIds(array $testdata)
 {
     $customercodes = $customerIds = array();
     foreach ($testdata['order/base'] as $key => $dataset) {
         $customercodes[] = $dataset['customerid'];
     }
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->additional, 'Standard');
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', $customercodes));
     foreach ($customerManager->searchItems($search) as $id => $customerItem) {
         $customerIds[$customerItem->getCode()] = $id;
     }
     return $customerIds;
 }
Exemplo n.º 22
0
 protected function getListItems()
 {
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context, 'Standard');
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', 'UTC003'));
     $search->setSlice(0, 1);
     $results = $manager->searchItems($search);
     if (($item = reset($results)) === false) {
         throw new \Exception('No customer item found');
     }
     $search = $this->object->createSearch();
     $expr = array($search->compare('==', 'customer.lists.parentid', $item->getId()), $search->compare('==', 'customer.lists.domain', 'text'), $search->compare('==', 'customer.lists.editor', $this->editor), $search->compare('==', 'customer.lists.type.code', 'default'));
     $search->setConditions($search->combine('&&', $expr));
     $search->setSortations(array($search->sort('+', 'customer.lists.position')));
     return $this->object->searchItems($search);
 }
Exemplo n.º 23
0
 /**
  * Returns the customer item for the given code
  *
  * @param string $code Unique customer code
  * @throws \Exception If no customer item is found
  * @return \Aimeos\MShop\Customer\Item\Iface Customer item object
  */
 protected function getCustomerItem($code = 'UTC001')
 {
     $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $search = $customerManager->createSearch();
     $search->setConditions($search->compare('==', 'customer.code', $code));
     $result = $customerManager->searchItems($search);
     if (($customer = reset($result)) === false) {
         throw new \RuntimeException('Customer item not found');
     }
     return $customer;
 }
Exemplo n.º 24
0
 public function testCreateManagerNotExisting()
 {
     $this->setExpectedException('\\Aimeos\\MShop\\Exception');
     \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperMShop::getContext(), 'unknown');
 }
Exemplo n.º 25
0
 public function testProcessDeleteItem()
 {
     $this->context->setUserId('123');
     $view = $this->object->getView();
     $param = array('wat_action' => 'delete', 'wat_id' => 321);
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $param);
     $view->addHelper('param', $helper);
     $listManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Lists\\Standard')->setMethods(array('deleteItems'))->setConstructorArgs(array($this->context))->getMock();
     $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')->setMethods(array('getSubManager'))->setConstructorArgs(array($this->context))->getMock();
     $name = 'ClientHtmlAccountWatchDefaultProcess';
     $this->context->getConfig()->set('mshop/customer/manager/name', $name);
     \Aimeos\MShop\Customer\Manager\Factory::injectManager('\\Aimeos\\MShop\\Customer\\Manager\\' . $name, $managerStub);
     $managerStub->expects($this->atLeastOnce())->method('getSubManager')->will($this->returnValue($listManagerStub));
     $listManagerStub->expects($this->once())->method('deleteItems');
     $this->object->process();
 }
Exemplo n.º 26
0
 protected function setUp()
 {
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelper::getContext(), 'Ezpublish');
     $this->object = $manager->getSubManager('lists', 'Ezpublish');
 }