public function testProcess() { $type = MShop_Order_Item_Base_Address_Abstract::TYPE_PAYMENT; $manager = 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('*****@*****.**'); $basketCntl = Controller_Frontend_Basket_Factory::createController($this->_context); $basketCntl->setAddress($type, $addrItem); $view = TestHelper::getView(); $view->orderBasket = $basketCntl->get(); $this->_object->setView($view); $orderBaseStub = $this->getMockBuilder('MShop_Order_Manager_Base_Default')->setConstructorArgs(array($this->_context))->setMethods(array('saveItem'))->getMock(); $customerStub = $this->getMockBuilder('MShop_Customer_Manager_Default')->setConstructorArgs(array($this->_context))->setMethods(array('saveItem'))->getMock(); $orderBaseStub->expects($this->once())->method('saveItem'); $customerStub->expects($this->once())->method('saveItem'); MShop_Factory::injectManager($this->_context, 'customer', $customerStub); MShop_Factory::injectManager($this->_context, 'order/base', $orderBaseStub); $this->_object->process(); }
public function testProcess() { $type = MShop_Order_Item_Base_Address_Abstract::TYPE_DELIVERY; $manager = 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 Exception('No customer item found'); } $addrItem = $customerItem->getPaymentAddress(); $addrItem->setId(null); $basketCntl = Controller_Frontend_Basket_Factory::createController($this->_context); $basketCntl->setAddress($type, $addrItem); $view = TestHelper::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()); }
public function testProcessOK() { $controller = Controller_Frontend_Basket_Factory::createController($this->_context); $baseManager = MShop_Order_Manager_Factory::createManager($this->_context)->getSubManager('base'); $serviceManager = 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 MW_View_Helper_Parameter_Default($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('MShop_Order_Item_Interface', $view->orderItem); $this->assertEquals($item->getId(), $view->orderItem->getBaseId()); }
public function testGetBody() { $controller = 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); }
public function testGetBody() { $controller = Controller_Frontend_Basket_Factory::createController($this->_context); $view = TestHelper::getView(); $view->standardBasket = $controller->get(); $this->_object->setView($view); $output = $this->_object->getBody(); $this->assertStringStartsWith('<div class="checkout-standard-summary-option container">', $output); }
public function testGetBody() { $controller = 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); }
public function testGetBody() { $controller = Controller_Frontend_Basket_Factory::createController($this->_context); $basket = $controller->get(); $basket->addCoupon('test'); $view = TestHelper::getView(); $view->standardBasket = $basket; $this->_object->setView($view); $output = $this->_object->getBody(); $this->assertStringStartsWith('<div class="common-summary-coupon', $output); }
public function testGetBody() { $controller = 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->assertStringStartsWith('<section class="basket-related-bought', $output); $this->assertContains('Cafe Noire Expresso', $output); }
public function testGetBody() { $controller = 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); }
public function testGetBodyAddedOneProduct() { $controller = 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-main">', $output); $this->assertRegExp('#9#smU', $output); $this->assertRegExp('#171.00#smU', $output); }
protected function _getBasket() { $customerManager = 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 = Controller_Frontend_Basket_Factory::createController($this->_context); $controller->setAddress(MShop_Order_Item_Base_Address_Abstract::TYPE_PAYMENT, $customer->getPaymentAddress()); $controller->setAddress(MShop_Order_Item_Base_Address_Abstract::TYPE_DELIVERY, $customer->getPaymentAddress()); return $controller->get(); }
public function testGetBodyDeleteCoupon() { $controller = Controller_Frontend_Basket_Factory::createController($this->_context); $controller->addProduct($this->_getProductItem('CNC')->getId(), 1, array(), array(), array(), array(), 'unit_warehouse2'); $view = $this->_object->getView(); $param = array('b-coupon' => '90AB'); $helper = new MW_View_Helper_Parameter_Default($view, $param); $view->addHelper('param', $helper); $this->_object->process(); $param = array('b-action' => 'coupon-delete', 'b-coupon' => '90AB'); $helper = new MW_View_Helper_Parameter_Default($view, $param); $view->addHelper('param', $helper); $this->_object->process(); $controller = Controller_Frontend_Basket_Factory::createController($this->_context); $view->standardBasket = $controller->get(); $output = $this->_object->getBody(); $this->assertNotRegExp('#<ul class="attr-list">#smU', $output); }
public function testProcessPrePay() { $orderManager = MShop_Order_Manager_Factory::createManager($this->_context); $serviceManager = 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'); } $basketCntl = Controller_Frontend_Basket_Factory::createController($this->_context); $basketCntl->setService('payment', $serviceItem->getId()); $orderItem = $orderManager->createItem(); $orderItem->setId(-1); $view = TestHelper::getView(); $view->orderItem = $orderItem; $view->orderBasket = $basketCntl->get(); $this->_object->setView($view); $this->_object->process(); $this->assertEquals(0, count($view->get('standardErrorList', array()))); $this->assertInstanceOf('MShop_Common_Item_Helper_Form_Interface', $view->get('paymentForm')); $this->assertEquals('REDIRECT', $view->paymentForm->getMethod()); $this->assertEquals('paymenturl', $view->paymentForm->getUrl()); }
/** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { Controller_Frontend_Basket_Factory::createController($this->_context)->clear(); unset($this->_object); }
public function testProcessExistingAddress() { $customerManager = 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.refid', $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 = TestHelper::getView(); $param = array('ca-delivery-option' => $address->getId()); $helper = new MW_View_Helper_Parameter_Default($view, $param); $view->addHelper('param', $helper); $this->_object->setView($view); $this->_object->process(); $this->_context->setEditor(null); $basket = Controller_Frontend_Basket_Factory::createController($this->_context)->get(); $this->assertEquals('Metaways', $basket->getAddress('delivery')->getCompany()); }
public function testCreateControllerNotExisting() { $this->setExpectedException('Controller_Frontend_Exception'); Controller_Frontend_Basket_Factory::createController(TestHelper::getContext(), 'notexist'); }
public function testProcessExistingId() { $serviceManager = MShop_Service_Manager_Factory::createManager($this->_context); $search = $serviceManager->createSearch(); $search->setConditions($search->compare('==', 'service.code', 'unitpaymentcode')); $result = $serviceManager->searchItems($search); if (($service = reset($result)) === false) { throw new Exception('Service item not found'); } $view = TestHelper::getView(); $param = array('c_paymentoption' => $service->getId()); $helper = new MW_View_Helper_Parameter_Default($view, $param); $view->addHelper('param', $helper); $this->_object->setView($view); $this->_object->process(); $basket = Controller_Frontend_Basket_Factory::createController($this->_context)->get(); $this->assertEquals('unitpaymentcode', $basket->getService('payment')->getCode()); }
public function testProcessExistingAddress() { $customer = $this->_getCustomerItem(); $this->_context->setUserId($customer->getId()); $view = TestHelper::getView(); $param = array('ca_billingoption' => $customer->getId()); $helper = new MW_View_Helper_Parameter_Default($view, $param); $view->addHelper('param', $helper); $this->_object->setView($view); $this->_object->process(); $this->_context->setEditor(null); $basket = Controller_Frontend_Basket_Factory::createController($this->_context)->get(); $this->assertEquals('Metaways', $basket->getAddress('payment')->getCompany()); }