Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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'));
 }