本文整理汇总了PHP中Aimeos\MShop\Service\Manager\Factory::injectManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::injectManager方法的具体用法?PHP Factory::injectManager怎么用?PHP Factory::injectManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aimeos\MShop\Service\Manager\Factory
的用法示例。
在下文中一共展示了Factory::injectManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRunExceptionProcess
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();
}
示例2: testUpdateNotAvailable
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());
}