Esempio n. 1
0
 public function testUpdate()
 {
     $context = \TestHelperCntl::getContext();
     $config = $context->getConfig();
     $name = 'ControllerCommonOrderBlock';
     $config->set('mshop/order/manager/name', $name);
     $config->set('mshop/product/manager/name', $name);
     $config->set('mshop/coupon/manager/name', $name);
     $orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
     $orderBaseManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
     $orderStatusManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Status\\Standard')->setMethods(array('saveItem', 'searchItems'))->setConstructorArgs(array($context))->getMock();
     $orderProductManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Product\\Standard')->setMethods(array('searchItems'))->setConstructorArgs(array($context))->getMock();
     $orderCouponManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Coupon\\Standard')->setMethods(array('searchItems'))->setConstructorArgs(array($context))->getMock();
     $productManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard')->setMethods(array('getSubManager', 'searchItems'))->setConstructorArgs(array($context))->getMock();
     $productStockManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Stock\\Standard')->setMethods(array('increase'))->setConstructorArgs(array($context))->getMock();
     $couponManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Coupon\\Manager\\Standard')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
     $couponCodeManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Coupon\\Manager\\Code\\Standard')->setMethods(array('increase'))->setConstructorArgs(array($context))->getMock();
     \Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub);
     \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $productManagerStub);
     \Aimeos\MShop\Coupon\Manager\Factory::injectManager('\\Aimeos\\MShop\\Coupon\\Manager\\' . $name, $couponManagerStub);
     $orderStatusItemBlocked = $orderStatusManagerStub->createItem();
     $orderStatusItemBlocked->setValue(1);
     $orderStatusItemUnblocked = $orderStatusManagerStub->createItem();
     $orderStatusItemUnblocked->setValue(0);
     $orderManagerStub->expects($this->exactly(12))->method('getSubManager')->will($this->onConsecutiveCalls($orderStatusManagerStub, $orderBaseManagerStub, $orderStatusManagerStub, $orderStatusManagerStub, $orderBaseManagerStub, $orderStatusManagerStub, $orderStatusManagerStub, $orderBaseManagerStub, $orderStatusManagerStub, $orderStatusManagerStub, $orderBaseManagerStub, $orderStatusManagerStub));
     $orderBaseManagerStub->expects($this->exactly(4))->method('getSubManager')->will($this->onConsecutiveCalls($orderProductManagerStub, $orderCouponManagerStub, $orderProductManagerStub, $orderCouponManagerStub));
     $orderStatusManagerStub->expects($this->exactly(4))->method('searchItems')->will($this->onConsecutiveCalls(array($orderStatusItemUnblocked), array($orderStatusItemUnblocked), array($orderStatusItemBlocked), array($orderStatusItemBlocked)));
     $orderStatusManagerStub->expects($this->exactly(4))->method('saveItem');
     $orderProductManagerStub->expects($this->exactly(2))->method('searchItems')->will($this->returnValue(array($orderProductManagerStub->createItem())));
     $productManagerStub->expects($this->exactly(4))->method('getSubManager')->will($this->returnValue($productStockManagerStub));
     $productManagerStub->expects($this->exactly(2))->method('searchItems')->will($this->returnValue(array()));
     $productStockManagerStub->expects($this->exactly(2))->method('increase');
     $orderCouponManagerStub->expects($this->exactly(2))->method('searchItems')->will($this->returnValue(array($orderCouponManagerStub->createItem())));
     $couponManagerStub->expects($this->exactly(2))->method('getSubManager')->will($this->returnValue($couponCodeManagerStub));
     $couponCodeManagerStub->expects($this->exactly(2))->method('increase');
     $orderItem = $orderManagerStub->createItem();
     $orderItem->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED);
     $object = new \Aimeos\Controller\Common\Order\Standard($context);
     $object->update($orderItem);
     $orderItem = $orderManagerStub->createItem();
     $orderItem->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_PENDING);
     $object = new \Aimeos\Controller\Common\Order\Standard($context);
     $object->update($orderItem);
     $orderItem = $orderManagerStub->createItem();
     $orderItem->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_DELETED);
     $object = new \Aimeos\Controller\Common\Order\Standard($context);
     $object->update($orderItem);
 }
Esempio n. 2
0
 public function testImportFile()
 {
     $codeMock = $this->getMockBuilder('\\Aimeos\\MShop\\Coupon\\Manager\\Code\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
     $codeMock->expects($this->exactly(3))->method('saveItem');
     $mock = $this->getMockBuilder('\\Aimeos\\MShop\\Coupon\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('getSubManager'))->getMock();
     $mock->expects($this->once())->method('getSubManager')->will($this->returnValue($codeMock));
     $name = 'ControllerExtJSCouponCodeDefaultRun';
     $this->context->getConfig()->set('mshop/coupon/manager/name', $name);
     \Aimeos\MShop\Coupon\Manager\Factory::injectManager('\\Aimeos\\MShop\\Coupon\\Manager\\' . $name, $mock);
     $testfiledir = __DIR__ . DIRECTORY_SEPARATOR . 'testfiles' . DIRECTORY_SEPARATOR;
     exec(sprintf('cp -r %1$s %2$s', escapeshellarg($testfiledir) . '*', escapeshellarg($this->testdir)));
     $params = new \stdClass();
     $params->site = $this->context->getLocale()->getSite()->getCode();
     $params->items = $this->testdir . DIRECTORY_SEPARATOR . 'coupon.zip';
     $params->parentid = '-1';
     $this->object->importFile($params);
 }