Esempio n. 1
0
 public function testUpdate()
 {
     $context = \TestHelper::getContext();
     $name = 'ControllerFrontendOrderUpdate';
     $context->getConfig()->set('controller/common/order/name', $name);
     $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard')->setMethods(array('update'))->setConstructorArgs(array($context))->getMock();
     \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub);
     $orderCntlStub->expects($this->once())->method('update');
     $object = new \Aimeos\Controller\Frontend\Order\Standard($context);
     $object->update(\Aimeos\MShop\Factory::createManager($context, 'order')->createItem());
 }
Esempio n. 2
0
 /**
  * Executes the job.
  *
  * @throws \Aimeos\Controller\Jobs\Exception If an error occurs
  */
 public function run()
 {
     $context = $this->getContext();
     $controller = \Aimeos\Controller\Common\Order\Factory::createController($context);
     $baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
     $manager = \Aimeos\MShop\Factory::createManager($context, 'order');
     /** controller/jobs/order/cleanup/unfinished/keep-hours
      * Release the ordered products after the configured time if no payment was confirmed
      *
      * After a customer creates an order and before he is redirected to the
      * payment provider (if necessary), the ordered products, coupon codes,
      * etc. are blocked for that customer. Normally, they should be released
      * a certain amount of time if no payment confirmation arrives so
      * customers can order the products and use the coupon codes again.
      *
      * The configured number of hours should be high enough to avoid releasing
      * products and coupon codes in case of temporary technical problems!
      *
      * The unfinished orders are deleted afterwards to keep the database clean.
      *
      * @param integer Number of hours
      * @since 2014.07
      * @category User
      */
     $hours = $context->getConfig()->get('controller/jobs/order/cleanup/unfinished/keep-hours', 24);
     $limit = date('Y-m-d H:i:s', time() - 3600 * $hours);
     $search = $manager->createSearch();
     $expr = array($search->compare('<', 'order.mtime', $limit), $search->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED));
     $search->setConditions($search->combine('&&', $expr));
     $start = 0;
     do {
         $baseIds = array();
         $items = $manager->searchItems($search);
         foreach ($items as $item) {
             $controller->unblock($item);
             $baseIds[] = $item->getBaseId();
         }
         $baseManager->deleteItems($baseIds);
         $count = count($items);
         $start += $count;
         $search->setSlice($start);
     } while ($count >= $search->getSliceSize());
 }
Esempio n. 3
0
 /**
  * Executes the job.
  *
  * @throws \Aimeos\Controller\Jobs\Exception If an error occurs
  */
 public function run()
 {
     $context = $this->getContext();
     $controller = \Aimeos\Controller\Common\Order\Factory::createController($context);
     $baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
     $manager = \Aimeos\MShop\Factory::createManager($context, 'order');
     /** controller/jobs/order/cleanup/unpaid/keep-days
      * Removes all orders from the database that are unpaid
      *
      * Orders with a payment status of deleted, canceled or refused are only
      * necessary for the records for a certain amount of time. Afterwards,
      * they can be deleted from the database most of the time.
      *
      * The number of days should be high enough to ensure that you keep the
      * orders as long as your customers will be asking what happend to their
      * orders.
      *
      * @param integer Number of days
      * @since 2014.07
      * @category User
      */
     $days = $context->getConfig()->get('controller/jobs/order/cleanup/unpaid/keep-days', 3);
     $limit = date('Y-m-d H:i:s', time() - 86400 * $days);
     $search = $manager->createSearch();
     $expr = array($search->compare('<', 'order.mtime', $limit), $search->compare('<', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_REFUND));
     $search->setConditions($search->combine('&&', $expr));
     $start = 0;
     do {
         $baseIds = array();
         $items = $manager->searchItems($search);
         foreach ($items as $item) {
             $controller->unblock($item);
             $baseIds[] = $item->getBaseId();
         }
         $baseManager->deleteItems($baseIds);
         $count = count($items);
         $start += $count;
         $search->setSlice($start);
     } while ($count >= $search->getSliceSize());
 }
Esempio n. 4
0
 public function testRun()
 {
     $context = \TestHelper::getContext();
     $aimeos = \TestHelper::getAimeos();
     $name = 'ControllerJobsOrderCleanupUnfinishedDefaultRun';
     $context->getConfig()->set('mshop/order/manager/name', $name);
     $context->getConfig()->set('controller/common/order/name', $name);
     $orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')->setMethods(array('searchItems', 'getSubManager'))->setConstructorArgs(array($context))->getMock();
     $orderBaseManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setMethods(array('deleteItems'))->setConstructorArgs(array($context))->getMock();
     $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard')->setMethods(array('unblock'))->setConstructorArgs(array($context))->getMock();
     \Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub);
     \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub);
     $orderItem = $orderManagerStub->createItem();
     $orderItem->setBaseId(1);
     $orderItem->setId(2);
     $orderManagerStub->expects($this->once())->method('getSubManager')->will($this->returnValue($orderBaseManagerStub));
     $orderManagerStub->expects($this->once())->method('searchItems')->will($this->returnValue(array($orderItem->getId() => $orderItem)));
     $orderBaseManagerStub->expects($this->once())->method('deleteItems');
     $orderCntlStub->expects($this->once())->method('unblock');
     $object = new \Aimeos\Controller\Jobs\Order\Cleanup\Unfinished\Standard($context, $aimeos);
     $object->run();
 }
Esempio n. 5
0
 public function testCreateControllerNotExisting()
 {
     $this->setExpectedException('\\Aimeos\\Controller\\Common\\Exception');
     \Aimeos\Controller\Common\Order\Factory::createController(\TestHelperCntl::getContext(), 'notexist');
 }
Esempio n. 6
0
 /**
  * Blocks or frees the resources listed in the order if necessary.
  *
  * After payment status updates, the resources like products or coupon
  * codes listed in the order must be blocked or unblocked. This method
  * cares about executing the appropriate action depending on the payment
  * status.
  *
  * It's save to call this method multiple times for one order. In this case,
  * the actions will be executed only once. All subsequent calls will do
  * nothing as long as the payment status hasn't changed in the meantime.
  *
  * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
  */
 public function update(\Aimeos\MShop\Order\Item\Iface $orderItem)
 {
     \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->update($orderItem);
 }