protected function setUp() { \Aimeos\MShop\Factory::setCache(true); $context = \TestHelperCntl::getContext(); $aimeos = \TestHelperCntl::getAimeos(); $this->object = new TestAbstract($context, $aimeos); }
public function testSet() { $item = \Aimeos\MShop\Factory::createManager(\TestHelperCntl::getContext(), 'product/stock/warehouse')->createItem(); $item->setCode('cache-test'); $item->setId(1); $this->object->set($item); $id = $this->object->get('cache-test'); $this->assertEquals($item->getId(), $id); }
protected function setUp() { $this->context = \TestHelperCntl::getContext(); $this->object = new \Aimeos\Controller\Common\Media\Standard($this->context); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { \Aimeos\MShop\Factory::setCache(true); $this->context = \TestHelperCntl::getContext(); $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, array()); }
protected function getOrderItem($datepayment) { $manager = \Aimeos\MShop\Factory::createManager(\TestHelperCntl::getContext(), 'order'); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'order.datepayment', $datepayment)); $result = $manager->searchItems($search); if (($item = reset($result)) === false) { throw new \RuntimeException(sprintf('No order item for payment date "%1$s" found', $datepayment)); } return $item; }
public function testCreateControllerNotExisting() { $this->setExpectedException('\\Aimeos\\Controller\\Common\\Exception'); \Aimeos\Controller\Common\Order\Factory::createController(\TestHelperCntl::getContext(), 'notexist'); }
protected function setUp() { \Aimeos\MShop\Factory::setCache(true); $context = \TestHelperCntl::getContext(); $this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Cache\Attribute\Standard($context); }
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')); }