本文整理汇总了PHP中Aimeos\MShop\Product\Manager\Factory::injectManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::injectManager方法的具体用法?PHP Factory::injectManager怎么用?PHP Factory::injectManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aimeos\MShop\Product\Manager\Factory
的用法示例。
在下文中一共展示了Factory::injectManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveJQAdmException
public function testSaveJQAdmException()
{
$object = $this->getMockBuilder('\\Aimeos\\Admin\\JQAdm\\Product\\Standard')->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))->setMethods(array('getSubClients'))->getMock();
$name = 'AdminJQAdmStandard';
$this->context->getConfig()->set('mshop/product/manager/name', $name);
$mock = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('createItem'))->getMock();
$mock->expects($this->exactly(2))->method('createItem')->will($this->throwException(new \Aimeos\Admin\JQAdm\Exception()));
\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $mock);
$object->setView($this->getViewNoRender());
$object->save();
}
示例2: getProductListsMock
protected function getProductListsMock(array $methods)
{
$name = 'ClientJsonAdmStandard';
$this->context->getConfig()->set('mshop/product/manager/lists/name', $name);
$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard')->setConstructorArgs(array($this->context))->setMethods($methods)->getMock();
\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub);
return $stub;
}
示例3: testUpdateStockBundle
public function testUpdateStockBundle()
{
$stockItems = array();
$context = \TestHelperCntl::getContext();
$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
$search = $productManager->createSearch();
$search->setConditions($search->compare('==', 'product.code', 'U:BUNDLE'));
$bundleItems = $productManager->searchItems($search, array('product'));
$name = 'ControllerCommonOrderUpdate';
$context->getConfig()->set('mshop/product/manager/name', $name);
$stockManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Stock\\Standard')->setMethods(array('saveItem', 'searchItems'))->setConstructorArgs(array($context))->getMock();
$productManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
$productManagerStub->expects($this->once())->method('getSubManager')->will($this->returnValue($stockManagerStub));
\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $productManagerStub);
$stock = 10;
$bundleStockItems = array();
foreach ($bundleItems as $bundleId => $bundleItem) {
foreach ($bundleItem->getRefItems('product', null, 'default') as $refItem) {
$stockItem = $stockManagerStub->createItem();
$stockItem->setParentId($refItem->getId());
$stockItem->setStockLevel($stock);
$stockItems[] = $stockItem;
$stock += 10;
}
$bundleStockItem = $stockManagerStub->createItem();
$bundleStockItem->setParentId($bundleId);
$bundleStockItem->setStockLevel($stock - 5);
$bundleStockItems[] = $bundleStockItem;
}
$fcn = function ($subject) {
return $subject->getStockLevel() === 10;
};
$stockManagerStub->expects($this->exactly(2))->method('searchItems')->will($this->onConsecutiveCalls($stockItems, $bundleStockItems));
$stockManagerStub->expects($this->exactly(1))->method('saveItem')->with($this->callback($fcn));
$class = new \ReflectionClass('\\Aimeos\\Controller\\Common\\Order\\Standard');
$method = $class->getMethod('updateStockBundle');
$method->setAccessible(true);
$object = new \Aimeos\Controller\Common\Order\Standard($context);
$method->invokeArgs($object, array($bundleItems, 'default'));
}