/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperMShop::getContext()); $orderBaseManager = $orderManager->getSubManager('base'); $this->order = $orderBaseManager->createItem(); $orderBaseProductManager = $orderBaseManager->getSubManager('product'); $search = $orderBaseProductManager->createSearch(); $search->setConditions($search->combine('&&', array($search->compare('==', 'order.base.product.prodcode', array('CNE', 'CNC')), $search->compare('==', 'order.base.product.price', array('600.00', '36.00'))))); $items = $orderBaseProductManager->searchItems($search); if (count($items) < 2) { throw new \Exception('Please fix the test data in your database.'); } foreach ($items as $item) { $this->products[$item->getProductCode()] = $item; } $this->products['CNE']->setQuantity(2); $this->products['CNC']->setQuantity(1); $config = array('min-value' => array('EUR' => '75.00'), 'max-value' => array('EUR' => '625.00'), 'min-products' => '2', 'max-products' => 5); $pluginManager = \Aimeos\MShop\Plugin\Manager\Factory::createManager(\TestHelperMShop::getContext()); $plugin = $pluginManager->createItem(); $plugin->setTypeId(2); $plugin->setProvider('BasketLimits'); $plugin->setConfig($config); $plugin->setStatus('1'); $this->object = new \Aimeos\MShop\Plugin\Provider\Order\BasketLimits(\TestHelperMShop::getContext(), $plugin); }
public function testCancel() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperMShop::getContext()); $orderItem = $manager->createItem(); $this->object->cancel($orderItem); $this->assertEquals(\Aimeos\MShop\Order\Item\Base::PAY_CANCELED, $orderItem->getPaymentStatus()); }
public function testProcess() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelper::getContext()); $order = $manager->createItem(); $this->object->process($order); $this->assertEquals(\Aimeos\MShop\Order\Item\Base::STAT_PROGRESS, $order->getDeliveryStatus()); }
public function testSaveDeleteItem() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperExtjs::getContext()); $baseManager = $manager->getSubManager('base'); $search = $baseManager->createSearch(); $search->setConditions($search->compare('==', 'order.base.price', '53.50')); $results = $baseManager->searchItems($search); if (($expected = reset($results)) === false) { throw new \Exception('No base item found'); } $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('order.base.service.baseid' => $expected->getId(), 'order.base.service.type' => 'delivery', 'order.base.service.code' => '74', 'order.base.service.name' => 'TestName')); $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => array('==' => (object) array('order.base.service.code' => '74'))))); $saved = $this->object->saveItems($saveParams); $searched = $this->object->searchItems($searchParams); $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'order.base.service.id'}); $this->object->deleteItems($deleteParams); $result = $this->object->searchItems($searchParams); $this->assertInternalType('object', $saved['items']); $this->assertNotNull($saved['items']->{'order.base.service.id'}); $this->assertEquals($saved['items']->{'order.base.service.id'}, $searched['items'][0]->{'order.base.service.id'}); $this->assertEquals($saved['items']->{'order.base.service.baseid'}, $searched['items'][0]->{'order.base.service.baseid'}); $this->assertEquals($saved['items']->{'order.base.service.type'}, $searched['items'][0]->{'order.base.service.type'}); $this->assertEquals($saved['items']->{'order.base.service.code'}, $searched['items'][0]->{'order.base.service.code'}); $this->assertEquals($saved['items']->{'order.base.service.name'}, $searched['items'][0]->{'order.base.service.name'}); $this->assertEquals(1, count($searched['items'])); $this->assertEquals(0, count($result['items'])); }
public function testSaveDeleteItem() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelper::getContext()); $baseManager = $manager->getSubManager('base'); $productManager = $baseManager->getSubManager('product'); $search = $productManager->createSearch(); $search->setConditions($search->compare('==', 'order.base.product.prodcode', 'CNE')); $results = $productManager->searchItems($search); if (($expected = reset($results)) === false) { throw new \Exception('No product item found'); } $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('order.base.product.attribute.productid' => $expected->getId(), 'order.base.product.attribute.code' => 'color', 'order.base.product.attribute.value' => 'purple', 'order.base.product.attribute.name' => 'Lila')); $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => array('==' => (object) array('order.base.product.attribute.name' => 'Lila'))))); $saved = $this->object->saveItems($saveParams); $searched = $this->object->searchItems($searchParams); $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'order.base.product.attribute.id'}); $this->object->deleteItems($deleteParams); $result = $this->object->searchItems($searchParams); $this->assertInternalType('object', $saved['items']); $this->assertNotNull($saved['items']->{'order.base.product.attribute.id'}); $this->assertEquals($saved['items']->{'order.base.product.attribute.id'}, $searched['items'][0]->{'order.base.product.attribute.id'}); $this->assertEquals($saved['items']->{'order.base.product.attribute.code'}, $searched['items'][0]->{'order.base.product.attribute.code'}); $this->assertEquals($saved['items']->{'order.base.product.attribute.value'}, $searched['items'][0]->{'order.base.product.attribute.value'}); $this->assertEquals($saved['items']->{'order.base.product.attribute.name'}, $searched['items'][0]->{'order.base.product.attribute.name'}); $this->assertEquals(1, count($searched['items'])); $this->assertEquals(0, count($result['items'])); }
public function testSaveDeleteItem() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperExtjs::getContext()); $baseManager = $manager->getSubManager('base'); $search = $baseManager->createSearch(); $search->setConditions($search->compare('==', 'order.base.price', '53.50')); $results = $baseManager->searchItems($search); if (($expected = reset($results)) === false) { throw new \RuntimeException('No base item found'); } $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('order.base.product.id' => null, 'order.base.product.baseid' => $expected->getId(), 'order.base.product.type' => 'default', 'order.base.product.suppliercode' => 'unitsupplier', 'order.base.product.prodcode' => 'EFGH22', 'order.base.product.name' => 'FoooBar', 'order.base.product.quantity' => 5, 'order.base.product.flags' => 0, 'order.base.product.status' => 1, 'order.base.product.position' => 5)); $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => array('==' => (object) array('order.base.product.name' => 'FoooBar')), 1 => array('==' => (object) array('order.base.product.prodcode' => 'EFGH22'))))); $saved = $this->object->saveItems($saveParams); $searched = $this->object->searchItems($searchParams); $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'order.base.product.id'}); $this->object->deleteItems($deleteParams); $result = $this->object->searchItems($searchParams); $this->assertInternalType('object', $saved['items']); $this->assertNotNull($saved['items']->{'order.base.product.id'}); $this->assertEquals($saved['items']->{'order.base.product.id'}, $searched['items'][0]->{'order.base.product.id'}); $this->assertEquals($saved['items']->{'order.base.product.baseid'}, $searched['items'][0]->{'order.base.product.baseid'}); $this->assertEquals($saved['items']->{'order.base.product.suppliercode'}, $searched['items'][0]->{'order.base.product.suppliercode'}); $this->assertEquals($saved['items']->{'order.base.product.prodcode'}, $searched['items'][0]->{'order.base.product.prodcode'}); $this->assertEquals($saved['items']->{'order.base.product.name'}, $searched['items'][0]->{'order.base.product.name'}); $this->assertEquals($saved['items']->{'order.base.product.quantity'}, $searched['items'][0]->{'order.base.product.quantity'}); $this->assertEquals($saved['items']->{'order.base.product.flags'}, $searched['items'][0]->{'order.base.product.flags'}); $this->assertEquals($saved['items']->{'order.base.product.status'}, $searched['items'][0]->{'order.base.product.status'}); $this->assertEquals(1, count($searched['items'])); $this->assertEquals(0, count($result['items'])); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $context = \TestHelper::getContext(); $pluginManager = \Aimeos\MShop\Plugin\Manager\Factory::createManager($context); $this->plugin = $pluginManager->createItem(); $this->plugin->setProvider('ProductGone'); $this->plugin->setStatus(1); $this->orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context); $orderBaseManager = $this->orderManager->getSubManager('base'); $search = $orderBaseManager->createSearch(); $search->setConditions($search->compare('==', 'order.base.price', 672.0)); $search->setSlice(0, 1); $items = $orderBaseManager->searchItems($search); if (($baseItem = reset($items)) === false) { throw new \Exception('No order base item found.'); } $this->order = $baseItem; // create a product to mess with in the tests $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelper::getContext()); $search = $productManager->createSearch(); $search->setConditions($search->compare('==', 'product.code', 'CNE')); $search->setSlice(0, 1); $items = $productManager->searchItems($search); if (($newProduct = reset($items)) === false) { throw new \Exception('Product code "CNE" not found.'); } $newProduct->setId(null); $newProduct->setLabel('Bad Product'); $newProduct->setCode('WTF'); $productManager->saveItem($newProduct); $this->product = $newProduct; }
public function testProcessOK() { $controller = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context); $baseManager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context)->getSubManager('base'); $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager($this->context); $search = $serviceManager->createSearch(); $search->setConditions($search->compare('==', 'service.code', 'unitpaymentcode')); $result = $serviceManager->searchItems($search); if (($serviceItem = reset($result)) === false) { throw new \Exception('No service item found'); } $controller->setService('payment', $serviceItem->getId()); $controller->setAddress('payment', array('order.base.address.languageid' => 'en')); $this->context->setUserId('-1'); $view = \TestHelper::getView(); $param = array('cs_order' => 1); $helper = new \Aimeos\MW\View\Helper\Parameter\Standard($view, $param); $view->addHelper('param', $helper); $this->object->setView($view); $this->object->process(); $search = $baseManager->createSearch(); $search->setConditions($search->compare('==', 'order.base.customerid', '-1')); $result = $baseManager->searchItems($search); if (($item = reset($result)) === false) { throw new \Exception('No order placed'); } $baseManager->deleteItem($item->getId()); $this->assertInstanceOf('\\Aimeos\\MShop\\Order\\Item\\Iface', $view->orderItem); $this->assertEquals($item->getId(), $view->orderItem->getBaseId()); }
/** * Adds order test data. */ protected function process() { $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface'; if (!$this->additional instanceof $iface) { throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface)); } $this->msg('Adding order test data', 0); $this->additional->setEditor('core:unittest'); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional, 'Standard'); $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->additional, 'Standard'); $orderBaseManager = $orderManager->getSubManager('base'); $search = $orderBaseManager->createSearch(); $search->setConditions($search->compare('==', 'order.base.sitecode', array('unittest', 'unit'))); foreach ($orderBaseManager->searchItems($search) as $order) { $orderBaseManager->deleteItem($order->getId()); } $ds = DIRECTORY_SEPARATOR; $path = __DIR__ . $ds . 'data' . $ds . 'order.php'; if (($testdata = (include $path)) == false) { throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for order domain', $path)); } $bases = $this->addOrderBaseData($localeManager, $orderBaseManager, $testdata); $bases['items'] = $this->addOrderBaseProductData($orderBaseManager, $bases, $testdata); $bases['items'] = $this->addOrderBaseServiceData($orderBaseManager, $bases, $testdata); //update order bases (getPrice) foreach ($bases['items'] as $baseItem) { $orderBaseManager->saveItem($baseItem, false); } $this->addOrderData($orderManager, $bases['ids'], $testdata); $this->status('done'); }
/** * Sets up the fixture. This method is called before a test is executed. */ protected function setUp() { $this->editor = \TestHelper::getContext()->getEditor(); $this->context = \TestHelper::getContext(); $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context); $this->object = $orderManager->getSubManager('base')->getSubManager('address'); }
public function testSaveDeleteItem() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelper::getContext()); $baseManager = $manager->getSubManager('base'); $search = $baseManager->createSearch(); $search->setConditions($search->compare('==', 'order.base.price', '53.50')); $results = $baseManager->searchItems($search); if (($expected = reset($results)) === false) { throw new \Exception('No items found.'); } $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('order.baseid' => $expected->getId(), 'order.type' => 'web', 'order.datepayment' => '2000-01-01 00:00:00', 'order.datedelivery' => '2001-01-01 00:00:00', 'order.statuspayment' => 2, 'order.statusdelivery' => 4, 'order.relatedid' => 55)); $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => array('==' => (object) array('order.relatedid' => 55))))); $saved = $this->object->saveItems($saveParams); $searched = $this->object->searchItems($searchParams); $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'order.id'}); $this->object->deleteItems($deleteParams); $result = $this->object->searchItems($searchParams); $this->assertInternalType('object', $saved['items']); $this->assertNotNull($saved['items']->{'order.id'}); $this->assertEquals($saved['items']->{'order.id'}, $searched['items'][0]->{'order.id'}); $this->assertEquals($saved['items']->{'order.baseid'}, $searched['items'][0]->{'order.baseid'}); $this->assertEquals($saved['items']->{'order.type'}, $searched['items'][0]->{'order.type'}); $this->assertEquals($saved['items']->{'order.datepayment'}, $searched['items'][0]->{'order.datepayment'}); $this->assertEquals($saved['items']->{'order.datedelivery'}, $searched['items'][0]->{'order.datedelivery'}); $this->assertEquals($saved['items']->{'order.statuspayment'}, $searched['items'][0]->{'order.statuspayment'}); $this->assertEquals($saved['items']->{'order.statusdelivery'}, $searched['items'][0]->{'order.statusdelivery'}); $this->assertEquals($saved['items']->{'order.relatedid'}, $searched['items'][0]->{'order.relatedid'}); $this->assertEquals(1, count($searched['items'])); $this->assertEquals(0, count($result['items'])); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $pluginManager = \Aimeos\MShop\Plugin\Manager\Factory::createManager(\TestHelper::getContext()); $this->plugin = $pluginManager->createItem(); $this->plugin->setTypeId(2); $this->plugin->setProvider('ProductLimit'); $this->plugin->setConfig(array('single-number-max' => 10)); $this->plugin->setStatus('1'); $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelper::getContext()); $orderBaseManager = $orderManager->getSubManager('base'); $orderBaseProductManager = $orderBaseManager->getSubManager('product'); $manager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelper::getContext()); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'product.code', array('CNE', 'CNC'))); $products = $manager->searchItems($search); if (count($products) !== 2) { throw new \Exception('Wrong number of products'); } $this->products = array(); foreach ($products as $product) { $item = $orderBaseProductManager->createItem(); $item->copyFrom($product); $this->products[$product->getCode()] = $item; } $this->order = $orderBaseManager->createItem(); $this->object = new \Aimeos\MShop\Plugin\Provider\Order\ProductLimit(\TestHelper::getContext(), $this->plugin); }
/** * Sets up the fixture, especially creates products. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $orderProducts = array(); $context = \TestHelper::getContext(); $this->couponItem = \Aimeos\MShop\Coupon\Manager\Factory::createManager($context)->createItem(); $provider = new \Aimeos\MShop\Coupon\Provider\Example($context, $this->couponItem, 'abcd'); $this->object = new \Aimeos\MShop\Coupon\Provider\Decorator\Required($context, $this->couponItem, 'abcd', $provider); $this->object->setObject($this->object); $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context); $orderBaseManager = $orderManager->getSubManager('base'); $orderProductManager = $orderBaseManager->getSubManager('product'); $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($context); $search = $productManager->createSearch(); $search->setConditions($search->compare('==', 'product.code', array('CNC'))); $products = $productManager->searchItems($search); $priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager($context); $price = $priceManager->createItem(); $price->setValue(321); foreach ($products as $product) { $orderProduct = $orderProductManager->createItem(); $orderProduct->copyFrom($product); $orderProducts[$product->getCode()] = $orderProduct; } $orderProducts['CNC']->setPrice($price); $this->orderBase = new \Aimeos\MShop\Order\Item\Base\Standard($priceManager->createItem(), $context->getLocale()); $this->orderBase->addProduct($orderProducts['CNC']); }
/** * Executes the job. * * @throws \Aimeos\Controller\Jobs\Exception If an error occurs */ public function run() { $context = $this->getContext(); /** controller/jobs/order/service/delivery/limit-days * Only start the delivery process of orders that were created in the past within the configured number of days * * The delivery process is normally started immediately after the * notification about a successful payment arrived. This option prevents * orders from being shipped in case anything went wrong or an update * failed and old orders would have been shipped now. * * @param integer Number of days * @since 2014.03 * @category User * @category Developer * @see controller/jobs/order/email/payment/standard/limit-days * @see controller/jobs/order/email/delivery/standard/limit-days */ $days = $context->getConfig()->get('controller/jobs/order/service/delivery/limit-days', 90); $date = date('Y-m-d 00:00:00', time() - 86400 * $days); $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager($context); $serviceSearch = $serviceManager->createSearch(); $serviceSearch->setConditions($serviceSearch->compare('==', 'service.type.code', 'delivery')); $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context); $orderSearch = $orderManager->createSearch(); $start = 0; do { $serviceItems = $serviceManager->searchItems($serviceSearch); foreach ($serviceItems as $serviceItem) { try { $serviceProvider = $serviceManager->getProvider($serviceItem); $expr = array($orderSearch->compare('==', 'order.siteid', $serviceItem->getSiteId()), $orderSearch->compare('>', 'order.datepayment', $date), $orderSearch->compare('>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING), $orderSearch->compare('==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED), $orderSearch->compare('==', 'order.base.service.code', $serviceItem->getCode()), $orderSearch->compare('==', 'order.base.service.type', 'delivery')); $orderSearch->setConditions($orderSearch->combine('&&', $expr)); $orderStart = 0; do { $orderItems = $orderManager->searchItems($orderSearch); foreach ($orderItems as $orderItem) { try { $serviceProvider->process($orderItem); $orderManager->saveItem($orderItem); } catch (\Exception $e) { $str = 'Error while processing order with ID "%1$s": %2$s'; $context->getLogger()->log(sprintf($str, $orderItem->getId(), $e->getMessage())); } } $orderCount = count($orderItems); $orderStart += $orderCount; $orderSearch->setSlice($orderStart); } while ($orderCount >= $orderSearch->getSliceSize()); } catch (\Exception $e) { $str = 'Error while processing service with ID "%1$s": %2$s'; $context->getLogger()->log(sprintf($str, $serviceItem->getId(), $e->getMessage())); } } $count = count($serviceItems); $start += $count; $serviceSearch->setSlice($start); } while ($count >= $serviceSearch->getSliceSize()); }
protected function getOrderBase($parts = null) { if ($parts === null) { $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ADDRESS | \Aimeos\MShop\Order\Manager\Base\Base::PARTS_SERVICE; } $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context)->getSubmanager('base'); return $manager->load($this->getOrder()->getBaseId(), $parts); }
public function testUpdateSync() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperMShop::getContext()); $order = $manager->createItem(); $this->object->expects($this->once())->method('getOrder')->will($this->returnValue($order)); $this->object->updateSync(array('orderid' => -1)); $this->assertEquals(\Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED, $order->getPaymentStatus()); }
public function testSaveDeleteItem() { $ctx = \TestHelper::getContext(); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); $siteManager = $localeManager->getSubManager('site'); $search = $siteManager->createSearch(); $search->setConditions($search->compare('==', 'locale.site.code', 'unittest')); $sites = $siteManager->searchItems($search); if (($siteItem = reset($sites)) === false) { throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Site item for code "%1$s" not found', $site)); } $localeItem = $localeManager->createItem(); $localeItem->setCurrencyId('EUR'); $localeItem->setLanguageId('en'); $localeItem->setSiteId($siteItem->getId()); $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($ctx); $baseManager = $manager->getSubManager('base'); $baseItem = $baseManager->createItem(); $baseItem->setCustomerId('unituser'); $baseItem->setComment('FoooBar'); $baseItem->setLocale($localeItem); $baseManager->saveItem($baseItem); $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('order.base.address.id' => null, 'order.base.address.baseid' => $baseItem->getId(), 'order.base.address.addressid' => '-1', 'order.base.address.type' => 'payment', 'order.base.address.company' => 'MusterMax', 'order.base.address.vatid' => 'DE999999999', 'order.base.address.salutation' => \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR, 'order.base.address.title' => 'Herr', 'order.base.address.firstname' => 'Max', 'order.base.address.lastname' => 'Mustermann', 'order.base.address.address1' => 'Addresse 1', 'order.base.address.address2' => 'Addresse 2', 'order.base.address.address3' => 'Addresse 3', 'order.base.address.postal' => '22222', 'order.base.address.city' => 'Hamburg', 'order.base.address.state' => 'Hamburg', 'order.base.address.countryid' => 'en', 'order.base.address.languageid' => 'en', 'order.base.address.telephone' => '0815-4711', 'order.base.address.email' => '*****@*****.**', 'order.base.address.telefax' => '0815-4712', 'order.base.address.website' => 'www.example.com')); $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => array('==' => (object) array('order.base.address.type' => 'payment')), 1 => array('==' => (object) array('order.base.address.baseid' => $baseItem->getId()))))); $savedAddress = $this->object->saveItems($saveParams); $searched = $this->object->searchItems($searchParams); $deleteParamsAddr = (object) array('site' => 'unittest', 'items' => $savedAddress['items']->{'order.base.address.id'}); $this->object->deleteItems($deleteParamsAddr); $baseManager->deleteItem($baseItem->getId()); $this->assertInternalType('object', $savedAddress['items']); $this->assertNotNull($savedAddress['items']->{'order.base.address.id'}); $this->assertEquals($savedAddress['items']->{'order.base.address.id'}, $searched['items'][0]->{'order.base.address.id'}); $this->assertEquals($savedAddress['items']->{'order.base.address.baseid'}, $searched['items'][0]->{'order.base.address.baseid'}); $this->assertEquals($savedAddress['items']->{'order.base.address.addressid'}, $searched['items'][0]->{'order.base.address.addressid'}); $this->assertEquals($savedAddress['items']->{'order.base.address.type'}, $searched['items'][0]->{'order.base.address.type'}); $this->assertEquals($savedAddress['items']->{'order.base.address.company'}, $searched['items'][0]->{'order.base.address.company'}); $this->assertEquals($savedAddress['items']->{'order.base.address.vatid'}, $searched['items'][0]->{'order.base.address.vatid'}); $this->assertEquals($savedAddress['items']->{'order.base.address.salutation'}, $searched['items'][0]->{'order.base.address.salutation'}); $this->assertEquals($savedAddress['items']->{'order.base.address.title'}, $searched['items'][0]->{'order.base.address.title'}); $this->assertEquals($savedAddress['items']->{'order.base.address.firstname'}, $searched['items'][0]->{'order.base.address.firstname'}); $this->assertEquals($savedAddress['items']->{'order.base.address.lastname'}, $searched['items'][0]->{'order.base.address.lastname'}); $this->assertEquals($savedAddress['items']->{'order.base.address.address1'}, $searched['items'][0]->{'order.base.address.address1'}); $this->assertEquals($savedAddress['items']->{'order.base.address.address2'}, $searched['items'][0]->{'order.base.address.address2'}); $this->assertEquals($savedAddress['items']->{'order.base.address.address3'}, $searched['items'][0]->{'order.base.address.address3'}); $this->assertEquals($savedAddress['items']->{'order.base.address.postal'}, $searched['items'][0]->{'order.base.address.postal'}); $this->assertEquals($savedAddress['items']->{'order.base.address.city'}, $searched['items'][0]->{'order.base.address.city'}); $this->assertEquals($savedAddress['items']->{'order.base.address.state'}, $searched['items'][0]->{'order.base.address.state'}); $this->assertEquals($savedAddress['items']->{'order.base.address.countryid'}, $searched['items'][0]->{'order.base.address.countryid'}); $this->assertEquals($savedAddress['items']->{'order.base.address.languageid'}, $searched['items'][0]->{'order.base.address.languageid'}); $this->assertEquals($savedAddress['items']->{'order.base.address.telephone'}, $searched['items'][0]->{'order.base.address.telephone'}); $this->assertEquals($savedAddress['items']->{'order.base.address.email'}, $searched['items'][0]->{'order.base.address.email'}); $this->assertEquals($savedAddress['items']->{'order.base.address.telefax'}, $searched['items'][0]->{'order.base.address.telefax'}); $this->assertEquals($savedAddress['items']->{'order.base.address.website'}, $searched['items'][0]->{'order.base.address.website'}); $this->assertEquals(1, count($searched['items'])); $searched = $this->object->searchItems($searchParams); $this->assertEquals(0, $searched['total']); $this->assertTrue($searched['success']); }
protected function setUp() { $this->context = \TestHelper::getContext(); $servManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); $this->servItem = $servManager->createItem(); $this->mockProvider = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Decorator\\Country')->disableOriginalConstructor()->getMock(); $this->basket = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context)->getSubManager('base')->createItem(); $this->object = new \Aimeos\MShop\Service\Provider\Decorator\Country($this->context, $this->servItem, $this->mockProvider); }
/** * @param string $date */ protected function getOrder($date) { $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context); $search = $orderManager->createSearch(); $search->setConditions($search->compare('==', 'order.datepayment', $date)); $result = $orderManager->searchItems($search); if (($item = reset($result)) === false) { throw new \Exception('No order found'); } return $item; }
public static function setUpBeforeClass() { $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelper::getContext()); $orderBaseManager = $orderManager->getSubManager('base'); $search = $orderManager->createSearch(); $search->setConditions($search->compare('==', 'order.datepayment', '2008-02-15 12:34:56')); $result = $orderManager->searchItems($search); if ((self::$orderItem = reset($result)) === false) { throw new \Exception('No order found'); } self::$orderBaseItem = $orderBaseManager->load(self::$orderItem->getBaseId()); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $context = \TestHelper::getContext(); $pluginManager = \Aimeos\MShop\Plugin\Manager\Factory::createManager($context); $this->plugin = $pluginManager->createItem(); $this->plugin->setProvider('ServicesAvailable'); $this->plugin->setStatus(1); $orderBaseManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); $orderBaseServiceManager = $orderBaseManager->getSubManager('service'); $this->order = $orderBaseManager->createItem(); $this->service = $orderBaseServiceManager->createItem(); }
protected function getOrderItem($customerid) { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context); $search = $manager->createSearch(true); $expr = array($search->getConditions(), $search->compare('==', 'order.base.customerid', $customerid)); $search->setConditions($search->combine('&&', $expr)); $items = $manager->searchItems($search); if (($item = reset($items)) === false) { throw new \Exception(sprintf('No order item for customer with ID "%1$s" found', $customerid)); } return $item; }
public function testUpdateAttributeExists() { $attributeManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperMShop::getContext())->getSubmanager('base')->getSubmanager('product')->getSubmanager('attribute'); $attribute = $attributeManager->createItem(); $attribute->setCode('product.stock.stocklevel'); $attribute->setName('product.stock.stocklevel'); $attribute->setValue('1200'); $attribute->setType('property'); $this->products['CNC']->setAttributes(array($attribute)); $this->assertEquals(1, count($this->products['CNC']->getAttributes())); $this->assertTrue($this->object->update($this->order, 'addProduct.before', $this->products['CNC'])); $this->assertEquals(4, count($this->products['CNC']->getAttributes())); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $context = \TestHelperMShop::getContext(); $pluginManager = \Aimeos\MShop\Plugin\Manager\Factory::createManager($context); $this->plugin = $pluginManager->createItem(); $this->plugin->setProvider('AddressesAvailable'); $this->plugin->setStatus(1); $orderBaseManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); $orderBaseAddressManager = $orderBaseManager->getSubManager('address'); $this->order = $orderBaseManager->createItem(); $this->address = $orderBaseAddressManager->createItem(); $this->address->setLastName('Available'); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $context = \TestHelperMShop::getContext(); $pluginManager = \Aimeos\MShop\Plugin\Manager\Factory::createManager($context); $this->plugin = $pluginManager->createItem(); $this->plugin->setTypeId(2); $this->plugin->setProvider('Shipping'); $this->plugin->setConfig(array('threshold' => array('EUR' => '34.00'))); $this->plugin->setStatus('1'); $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context); $orderBaseManager = $orderManager->getSubManager('base'); $orderBaseProductManager = $orderBaseManager->getSubManager('product'); $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($context); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'product.code', array('CNE', 'CNC', 'IJKL'))); $pResults = $manager->searchItems($search, array('price')); if (count($pResults) !== 3) { throw new \RuntimeException('Wrong number of products'); } $products = array(); foreach ($pResults as $prod) { $products[$prod->getCode()] = $prod; } if (($price = current($products['IJKL']->getRefItems('price'))) === false) { throw new \RuntimeException('No price item found'); } $price->setValue(10.0); $this->product = $orderBaseProductManager->createItem(); $this->product->copyFrom($products['CNE']); $this->product->setPrice($price); $product2 = $orderBaseProductManager->createItem(); $product2->copyFrom($products['CNC']); $product2->setPrice($price); $product3 = $orderBaseProductManager->createItem(); $product3->copyFrom($products['IJKL']); $product3->setPrice($price); $orderBaseServiceManager = $orderBaseManager->getSubManager('service'); $serviceSearch = $orderBaseServiceManager->createSearch(); $exp = array($serviceSearch->compare('==', 'order.base.service.type', 'delivery'), $serviceSearch->compare('==', 'order.base.service.costs', '5.00')); $serviceSearch->setConditions($serviceSearch->combine('&&', $exp)); $results = $orderBaseServiceManager->searchItems($serviceSearch); if (($delivery = reset($results)) === false) { throw new \RuntimeException('No order base item found'); } $this->order = $orderBaseManager->createItem(); $this->order->setService($delivery, 'delivery'); $this->order->addProduct($this->product); $this->order->addProduct($product2); $this->order->addProduct($product3); $this->object = new \Aimeos\MShop\Plugin\Provider\Order\Shipping($context, $this->plugin); }
public function testGetBody() { $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'order.base.service.code', 'paypalexpress')); $items = $manager->searchItems($search); if (($item = reset($items)) === false) { throw new \Exception('No item found'); } $view = \TestHelperHtml::getView(); $view->confirmOrderItem = $item; $this->object->setView($view); $output = $this->object->getBody(); $this->assertStringStartsWith('<div class="checkout-confirm-retry">', $output); }
public function testRunException() { $context = \TestHelper::getContext(); $aimeos = \TestHelper::getAimeos(); $mailStub = $this->getMockBuilder('\\Aimeos\\MW\\Mail\\None')->disableOriginalConstructor()->getMock(); $context->setMail($mailStub); $name = 'ControllerJobsEmailPaymentDefaultRun'; $context->getConfig()->set('mshop/order/manager/name', $name); $orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')->setMethods(array('searchItems'))->setConstructorArgs(array($context))->getMock(); \Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub); $orderItem = $orderManagerStub->createItem(); $orderManagerStub->expects($this->exactly(4))->method('searchItems')->will($this->onConsecutiveCalls(array($orderItem), array(), array(), array())); $object = new \Aimeos\Controller\Jobs\Order\Email\Payment\Standard($context, $aimeos); $object->run(); }
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); }
public function testStore() { $context = \TestHelper::getContext(); $name = 'ControllerFrontendOrderStore'; $context->getConfig()->set('mshop/order/manager/name', $name); $orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')->setMethods(array('saveItem', 'getSubManager'))->setConstructorArgs(array($context))->getMock(); $orderBaseManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setMethods(array('store'))->setConstructorArgs(array($context))->getMock(); \Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub); $orderBaseItem = $orderBaseManagerStub->createItem(); $orderBaseItem->setId(1); $orderBaseManagerStub->expects($this->once())->method('store'); $orderManagerStub->expects($this->once())->method('getSubManager')->will($this->returnValue($orderBaseManagerStub)); $orderManagerStub->expects($this->once())->method('saveItem'); $object = new \Aimeos\Controller\Frontend\Order\Standard($context); $object->store($orderBaseItem); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $context = \TestHelperMShop::getContext(); $couponItem = \Aimeos\MShop\Coupon\Manager\Factory::createManager($context)->createItem(); $couponItem->setConfig(array('freeshipping.productcode' => 'U:SD')); $this->object = new \Aimeos\MShop\Coupon\Provider\FreeShipping($context, $couponItem, 'zyxw'); $delPrice = \Aimeos\MShop\Price\Manager\Factory::createManager($context)->createItem(); $delPrice->setCosts('5.00'); $delPrice->setCurrencyId('EUR'); $priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager($context); $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base')->getSubManager('service'); $delivery = $manager->createItem(); $delivery->setCode('test'); $delivery->setType('delivery'); $delivery->setPrice($delPrice); // Don't create order base item by createItem() as this would already register the plugins $this->orderBase = new \Aimeos\MShop\Order\Item\Base\Standard($priceManager->createItem(), $context->getLocale()); $this->orderBase->setService($delivery, 'delivery'); }