public function testRunExceptionProcess() { $context = TestHelper::getContext(); $arcavias = TestHelper::getArcavias(); $name = 'ControllerJobsServiceAsyncProcessDefaultRun'; $context->getConfig()->set('classes/service/manager/name', $name); $serviceManagerStub = $this->getMockBuilder('MShop_Service_Manager_Default')->setMethods(array('getProvider', 'searchItems'))->setConstructorArgs(array($context))->getMock(); MShop_Service_Manager_Factory::injectManager('MShop_Service_Manager_' . $name, $serviceManagerStub); $serviceItem = $serviceManagerStub->createItem(); $serviceManagerStub->expects($this->once())->method('searchItems')->will($this->onConsecutiveCalls(array($serviceItem), array())); $serviceManagerStub->expects($this->once())->method('getProvider')->will($this->throwException(new MShop_Service_Exception())); $object = new Controller_Jobs_Order_Service_Async_Default($context, $arcavias); $object->run(); }
public function testUpdateNotAvailable() { $context = TestHelper::getContext(); $object = new MShop_Plugin_Provider_Order_ServicesUpdate($context, $this->_plugin); $priceManager = MShop_Factory::createManager($context, 'price'); $localeManager = MShop_Factory::createManager($context, 'locale'); $orderBaseProductManager = MShop_Factory::createManager($context, 'order/base/product'); $orderBaseServiceManager = MShop_Factory::createManager($context, 'order/base/service'); $priceItem = $priceManager->createItem(); $localeItem = $localeManager->createItem(); $orderProduct = $orderBaseProductManager->createItem(); $serviceDelivery = $orderBaseServiceManager->createItem(); $serviceDelivery->setServiceId(1); $servicePayment = $orderBaseServiceManager->createItem(); $servicePayment->setServiceId(2); $orderStub = $this->getMockBuilder('MShop_Order_Item_Base_Default')->setConstructorArgs(array($priceItem, $localeItem))->setMethods(array('getProducts'))->getMock(); $serviceStub = $this->getMockBuilder('MShop_Service_Manager_Default')->setConstructorArgs(array($context))->setMethods(array('searchItems', 'getProvider'))->getMock(); MShop_Service_Manager_Factory::injectManager('MShop_Service_Manager_PluginServicesUpdate', $serviceStub); $context->getConfig()->set('classes/service/manager/name', 'PluginServicesUpdate'); $orderStub->setService($serviceDelivery, 'delivery'); $orderStub->setService($servicePayment, 'payment'); $serviceItemDelivery = new MShop_Service_Item_Default(array('type' => 'delivery')); $serviceItemPayment = new MShop_Service_Item_Default(array('type' => 'payment')); $providerStub = $this->getMockBuilder('MShop_Service_Provider_Delivery_Manual')->setConstructorArgs(array($context, $serviceStub->createItem()))->setMethods(array('isAvailable'))->getMock(); $orderStub->expects($this->once())->method('getProducts')->will($this->returnValue(array($orderProduct))); $serviceStub->expects($this->once())->method('searchItems')->will($this->returnValue(array(1 => $serviceItemDelivery, 2 => $serviceItemPayment))); $serviceStub->expects($this->exactly(2))->method('getProvider')->will($this->returnValue($providerStub)); $providerStub->expects($this->exactly(2))->method('isAvailable')->will($this->returnValue(false)); $this->assertTrue($object->update($orderStub, 'addProduct.after')); $this->assertEquals(array(), $orderStub->getServices()); }