Esempio n. 1
0
 public function testRunExceptionProcess()
 {
     $context = \TestHelper::getContext();
     $aimeos = \TestHelper::getAimeos();
     $name = 'ControllerJobsServiceAsyncProcessDefaultRun';
     $context->getConfig()->set('mshop/service/manager/name', $name);
     $serviceManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard')->setMethods(array('getProvider', 'searchItems'))->setConstructorArgs(array($context))->getMock();
     \Aimeos\MShop\Service\Manager\Factory::injectManager('\\Aimeos\\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 \Aimeos\MShop\Service\Exception()));
     $object = new \Aimeos\Controller\Jobs\Order\Service\Async\Standard($context, $aimeos);
     $object->run();
 }
 public function testUpdateNotAvailable()
 {
     $context = \TestHelper::getContext();
     $object = new \Aimeos\MShop\Plugin\Provider\Order\ServicesUpdate($context, $this->plugin);
     $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
     $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
     $orderBaseProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product');
     $orderBaseServiceManager = \Aimeos\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('\\Aimeos\\MShop\\Order\\Item\\Base\\Standard')->setConstructorArgs(array($priceItem, $localeItem))->setMethods(array('getProducts'))->getMock();
     $serviceStub = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard')->setConstructorArgs(array($context))->setMethods(array('searchItems', 'getProvider'))->getMock();
     \Aimeos\MShop\Service\Manager\Factory::injectManager('\\Aimeos\\MShop\\Service\\Manager\\PluginServicesUpdate', $serviceStub);
     $context->getConfig()->set('mshop/service/manager/name', 'PluginServicesUpdate');
     $orderStub->setService($serviceDelivery, 'delivery');
     $orderStub->setService($servicePayment, 'payment');
     $serviceItemDelivery = new \Aimeos\MShop\Service\Item\Standard(array('type' => 'delivery'));
     $serviceItemPayment = new \Aimeos\MShop\Service\Item\Standard(array('type' => 'payment'));
     $providerStub = $this->getMockBuilder('\\Aimeos\\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());
 }