コード例 #1
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();
 }
コード例 #2
0
ファイル: StandardTest.php プロジェクト: mvnp/aimeos-core
 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();
 }
コード例 #3
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());
 }
コード例 #4
0
 public function testProcessOK()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $baseManager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context)->getSubManager('base');
     $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager($this->context);
     $search = $serviceManager->createSearch();
     $search->setConditions($search->compare('==', 'service.code', 'unitpaymentcode'));
     $result = $serviceManager->searchItems($search);
     if (($serviceItem = reset($result)) === false) {
         throw new \Exception('No service item found');
     }
     $controller->setService('payment', $serviceItem->getId());
     $controller->setAddress('payment', array('order.base.address.languageid' => 'en'));
     $this->context->setUserId('-1');
     $view = \TestHelper::getView();
     $param = array('cs_order' => 1);
     $helper = new \Aimeos\MW\View\Helper\Parameter\Standard($view, $param);
     $view->addHelper('param', $helper);
     $this->object->setView($view);
     $this->object->process();
     $search = $baseManager->createSearch();
     $search->setConditions($search->compare('==', 'order.base.customerid', '-1'));
     $result = $baseManager->searchItems($search);
     if (($item = reset($result)) === false) {
         throw new \Exception('No order placed');
     }
     $baseManager->deleteItem($item->getId());
     $this->assertInstanceOf('\\Aimeos\\MShop\\Order\\Item\\Iface', $view->orderItem);
     $this->assertEquals($item->getId(), $view->orderItem->getBaseId());
 }
コード例 #5
0
ファイル: StandardTest.php プロジェクト: mvnp/aimeos-core
 public function testGetBody()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $view = $this->object->getView();
     $view->standardBasket = $controller->get();
     $output = $this->object->getBody();
     $this->assertStringStartsWith('<div class="common-summary-detail container">', $output);
 }
コード例 #6
0
ファイル: StandardTest.php プロジェクト: mvnp/aimeos-core
 public function testGetBody()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $view = \TestHelperHtml::getView();
     $view->standardBasket = $controller->get();
     $this->object->setView($view);
     $output = $this->object->getBody();
     $this->assertStringStartsWith('<div class="checkout-standard-summary-option container">', $output);
 }
コード例 #7
0
 public function testGetBody()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $view = \TestHelper::getView();
     $view->standardStepActive = 'summary';
     $view->standardBasket = $controller->get();
     $view->standardSteps = array('before', 'summary');
     $this->object->setView($view);
     $output = $this->object->getBody();
     $this->assertStringStartsWith('<section class="checkout-standard-summary common-summary">', $output);
 }
コード例 #8
0
 public function testGetBody()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $basket = $controller->get();
     $basket->addProduct($this->getOrderProductItem('CNC'));
     $view = $this->object->getView();
     $view->relatedBasket = $basket;
     $output = $this->object->getBody();
     $this->assertContains('<section class="basket-related-bought', $output);
     $this->assertContains('Cafe Noire Expresso', $output);
 }
コード例 #9
0
 public function testGetBody()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $controller->addProduct($this->getProductItem('CNE')->getId(), 1, array(), array(), array(), array(), array(), 'default');
     $view = \TestHelper::getView();
     $view->standardBasket = $controller->get();
     $this->object->setView($view);
     $output = $this->object->getBody();
     $this->assertStringStartsWith('<div class="common-summary-detail container">', $output);
     $this->assertRegExp('#<tfoot>.*<tr class="tax">.*<td class="price">3.03 .+</td>.*.*</tfoot>#smU', $output);
 }
コード例 #10
0
 public function testGetBody()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $basket = $controller->get();
     $basket->addCoupon('OPQR');
     $view = \TestHelper::getView();
     $view->standardBasket = $basket;
     $this->object->setView($view);
     $output = $this->object->getBody();
     $this->assertStringStartsWith('<div class="common-summary-coupon', $output);
 }
コード例 #11
0
 public function testGetBodyAddedOneProduct()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $productItem = $this->getProductItem('CNE');
     $view = $this->object->getView();
     $controller->addProduct($productItem->getId(), 9, array(), array(), array(), array(), array(), 'default');
     $view->miniBasket = $controller->get();
     $output = $this->object->getBody();
     $controller->clear();
     $this->assertStringStartsWith('<div class="basket-mini-product">', $output);
     $this->assertRegExp('#9#smU', $output);
     $this->assertRegExp('#171.00#smU', $output);
 }
コード例 #12
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();
 }
コード例 #13
0
 public function testProcessExistingId()
 {
     $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager($this->context);
     $search = $serviceManager->createSearch();
     $search->setConditions($search->compare('==', 'service.code', 'unitcode'));
     $result = $serviceManager->searchItems($search);
     if (($service = reset($result)) === false) {
         throw new \RuntimeException('Service item not found');
     }
     $view = \TestHelperHtml::getView();
     $param = array('c_deliveryoption' => $service->getId());
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $param);
     $view->addHelper('param', $helper);
     $this->object->setView($view);
     $this->object->process();
     $basket = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context)->get();
     $this->assertEquals('unitcode', $basket->getService('delivery')->getCode());
 }
コード例 #14
0
 public function testGetBodyDeleteCoupon()
 {
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $controller->addProduct($this->getProductItem('CNC')->getId(), 1, array(), array(), array(), array(), array(), 'default');
     $view = $this->object->getView();
     $param = array('b_coupon' => '90AB');
     $helper = new \Aimeos\MW\View\Helper\Parameter\Standard($view, $param);
     $view->addHelper('param', $helper);
     $this->object->process();
     $param = array('b_action' => 'coupon-delete', 'b_coupon' => '90AB');
     $helper = new \Aimeos\MW\View\Helper\Parameter\Standard($view, $param);
     $view->addHelper('param', $helper);
     $this->object->process();
     $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $view->standardBasket = $controller->get();
     $output = $this->object->getBody();
     $this->assertNotRegExp('#<ul class="attr-list">#smU', $output);
 }
コード例 #15
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context)->clear();
     unset($this->object);
 }
コード例 #16
0
 public function testCreateControllerNotExisting()
 {
     $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception');
     \Aimeos\Controller\Frontend\Basket\Factory::createController(\TestHelper::getContext(), 'notexist');
 }
コード例 #17
0
 public function testProcessExistingAddress()
 {
     $customer = $this->getCustomerItem();
     $this->context->setUserId($customer->getId());
     $view = \TestHelperHtml::getView();
     $param = array('ca_billingoption' => $customer->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('payment')->getCompany());
 }
コード例 #18
0
ファイル: StandardTest.php プロジェクト: mvnp/aimeos-core
 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());
 }
コード例 #19
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();
 }