/** * 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 testSaveUpdateDeleteItem() { // insert case $item = $this->object->createItem(); $item->setLabel('new name'); $item->setStatus(1); $item->setCode('xx'); $this->object->saveItem($item); $itemSaved = $this->object->getItem($item->getId()); // update case $itemExp = clone $itemSaved; $itemExp->setLabel('new new name'); $this->object->saveItem($itemExp); $itemUpd = $this->object->getItem($itemExp->getId()); $this->object->deleteItem($item->getId()); $context = \TestHelperMShop::getContext(); $this->assertTrue($item->getId() !== null); $this->assertEquals($item->getId(), $itemSaved->getId()); $this->assertEquals($item->getLabel(), $itemSaved->getLabel()); $this->assertEquals($item->getStatus(), $itemSaved->getStatus()); $this->assertEquals($item->getCode(), $itemSaved->getCode()); $this->assertEquals($context->getEditor(), $itemSaved->getEditor()); $this->assertRegExp('/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/', $itemSaved->getTimeCreated()); $this->assertRegExp('/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/', $itemSaved->getTimeModified()); $this->assertEquals($itemExp->getId(), $itemUpd->getId()); $this->assertEquals($itemExp->getStatus(), $itemUpd->getStatus()); $this->assertEquals($itemExp->getCode(), $itemUpd->getCode()); $this->assertEquals($itemExp->getLabel(), $itemUpd->getLabel()); $this->assertEquals($context->getEditor(), $itemUpd->getEditor()); $this->assertEquals($itemExp->getTimeCreated(), $itemUpd->getTimeCreated()); $this->assertRegExp('/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/', $itemUpd->getTimeModified()); $this->setExpectedException('\\Aimeos\\MShop\\Exception'); $this->object->getItem($item->getId()); }
protected function setUp() { $this->editor = \TestHelperMShop::getContext()->getEditor(); $this->context = \TestHelperMShop::getContext(); $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context); $this->object = $orderManager->getSubManager('base')->getSubManager('address'); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->context = \TestHelperMShop::getContext(); $this->editor = $this->context->getEditor(); $manager = \Aimeos\MShop\Price\Manager\Factory::createManager($this->context, 'Standard'); $this->object = $manager->getSubManager('lists', 'Standard'); }
protected function setUp() { $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager(\TestHelperMShop::getContext()); $this->siteItem = $manager->getSubManager('site')->createItem(); $this->values = array('locale.id' => 1, 'locale.siteid' => 1, 'locale.languageid' => 'de', 'locale.currencyid' => 'EUR', 'locale.position' => 1, 'locale.status' => 1, 'locale.mtime' => '2011-01-01 00:00:02', 'locale.ctime' => '2011-01-01 00:00:01', 'locale.editor' => 'unitTestUser'); $this->object = new \Aimeos\MShop\Locale\Item\Standard($this->values, $this->siteItem, array(1, 2), array(1, 3, 4)); }
/** * Sets up the fixture. This method is called before a test is executed. */ protected function setUp() { $this->editor = \TestHelperMShop::getContext()->getEditor(); $this->object = new \Aimeos\MShop\Customer\Manager\Standard(\TestHelperMShop::getContext()); $this->fixture = array('customer.label' => 'unitTest', 'customer.status' => 2); $this->address = new \Aimeos\MShop\Common\Item\Address\Standard('customer.'); }
/** * Sets up the fixture, especially creates products. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $orderProducts = array(); $context = \TestHelperMShop::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($provider, $context, $this->couponItem, 'abcd'); $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']); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->editor = \TestHelperMShop::getContext()->getEditor(); $attributeManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperMShop::getContext()); $attributeListManager = $attributeManager->getSubManager('lists'); $this->object = $attributeListManager->getSubManager('type'); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->editor = \TestHelperMShop::getContext()->getEditor(); $manager = \Aimeos\MShop\Service\Manager\Factory::createManager(\TestHelperMShop::getContext()); $listManager = $manager->getSubManager('lists'); $this->object = $listManager->getSubManager('type'); }
protected function setUp() { $this->context = \TestHelperMShop::getContext('unitperf'); // parser warm up so files are already parsed (same as APC is used) $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); $this->root = $catalogManager->getTree(null, array('text', 'media'), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->context = \TestHelperMShop::getContext(); $config = $this->context->getConfig(); $config->set('mshop/common/manager/decorators/default', array()); $config->set('mshop/attribute/manager/decorators/global', array()); $config->set('mshop/attribute/manager/decorators/local', array()); }
/** * Returns the Aimeos bootstrap object * * @return \Aimeos\Bootstrap Aimeos bootstrap object */ private static function getAimeos() { if (!isset(self::$aimeos)) { require_once dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'Bootstrap.php'; self::$aimeos = new \Aimeos\Bootstrap(array(), false); } return self::$aimeos; }
public function testSetLocale() { $locale = \Aimeos\MShop\Locale\Manager\Factory::createManager(\TestHelperMShop::getContext())->createItem(); $return = $this->object->setLocale($locale); $this->assertInstanceOf('\\Aimeos\\MShop\\Order\\Item\\Base\\Iface', $return); $this->assertEquals($locale, $this->object->getLocale()); $this->assertTrue($this->object->isModified()); }
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()); }
protected function setUp() { $context = \TestHelperMShop::getContext(); $dbm = $context->getDatabaseManager(); $conn = $dbm->acquire(); $this->object = new \Aimeos\MW\Criteria\MySQL($conn); $dbm->release($conn); }
protected function setUp() { $this->context = \TestHelperMShop::getContext(); $servManager = \Aimeos\MShop\Service\Manager\Factory::createManager($this->context); $this->servItem = $servManager->createItem(); $this->mockProvider = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Decorator\\Example')->disableOriginalConstructor()->getMock(); $this->object = new \Aimeos\MShop\Service\Provider\Decorator\Weight($this->mockProvider, $this->context, $this->servItem); }
public function testAddCouponInvalidConfig() { $context = \TestHelperMShop::getContext(); $couponItem = \Aimeos\MShop\Coupon\Manager\Factory::createManager(\TestHelperMShop::getContext())->createItem(); $object = new \Aimeos\MShop\Coupon\Provider\FreeShipping($context, $couponItem, 'zyxw'); $this->setExpectedException('\\Aimeos\\MShop\\Coupon\\Exception'); $object->addCoupon($this->orderBase); }
protected function setUp() { $this->context = \TestHelperMShop::getContext(); $servManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); $this->servItem = $servManager->createItem(); $this->mockProvider = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Decorator\\Currency')->disableOriginalConstructor()->getMock(); $this->basket = \Aimeos\MShop\Order\Manager\Factory::createManager($this->context)->getSubManager('base')->createItem(); $this->object = new \Aimeos\MShop\Service\Provider\Decorator\Currency($this->mockProvider, $this->context, $this->servItem); }
protected function setUp() { $context = \TestHelperMShop::getContext(); $priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager($context); $item = \Aimeos\MShop\Coupon\Manager\Factory::createManager($context)->createItem(); // 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->object = new \Aimeos\MShop\Coupon\Provider\None($context, $item, '1234'); }
/** * 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); $item = $pluginManager->createItem(); $provider = new \Aimeos\MShop\Plugin\Provider\Order\Example($context, $item); $priceItem = \Aimeos\MShop\Price\Manager\Factory::createManager($context)->createItem(); $this->order = new \Aimeos\MShop\Order\Item\Base\Standard($priceItem, $context->getLocale()); $this->object = new \Aimeos\MShop\Plugin\Provider\Decorator\Log($context, $item, $provider); }
protected function setUp() { $context = clone \TestHelperMShop::getContext(); $config = $context->getConfig(); $dbadapter = $config->get('resource/db-index/adapter', $config->get('resource/db/adapter')); if ($dbadapter !== 'pgsql') { $this->markTestSkipped('PostgreSQL specific test'); } $this->object = new \Aimeos\MShop\Index\Manager\Text\PgSQL(\TestHelperMShop::getContext()); }
public function testSetConfigFE() { $item = \Aimeos\MShop\Factory::createManager(\TestHelperMShop::getContext(), 'order/base/service')->createItem(); $this->object->setConfigFE($item, array('test.code' => 'abc', 'test.number' => 123)); $this->assertEquals(2, count($item->getAttributes())); $this->assertEquals('abc', $item->getAttribute('test.code', 'delivery')); $this->assertEquals(123, $item->getAttribute('test.number', 'delivery')); $this->assertEquals('delivery', $item->getAttributeItem('test.code', 'delivery')->getType()); $this->assertEquals('delivery', $item->getAttributeItem('test.number', 'delivery')->getType()); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->context = \TestHelperMShop::getContext(); $pluginManager = \Aimeos\MShop\Factory::createManager($this->context, 'plugin'); $this->plugin = $pluginManager->createItem(); $this->plugin->setProvider('ProductCode'); $this->plugin->setStatus(1); $orderBaseManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base'); $this->order = $orderBaseManager->createItem(); }
public function testInsertMoveItem() { $item = $this->object->createItem(); $parent = $this->object->getTree(null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE); $this->object->insertItem($item, $parent->getId()); $this->object->moveItem($item->getId(), $parent->getId(), $parent->getId()); $savedItem = $this->object->getItem($item->getId()); $this->object->deleteItem($item->getId()); $this->assertEquals($item->getId(), $savedItem->getId()); $this->assertEquals(\TestHelperMShop::getContext()->getEditor(), $savedItem->getEditor()); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->context = \TestHelperMShop::getContext(); $this->mock = $this->getMockBuilder('\\Aimeos\\MW\\Cache\\DB')->disableOriginalConstructor()->getMock(); $manager = $this->getMockBuilder('\\Aimeos\\MAdmin\\Cache\\Manager\\Standard')->setConstructorArgs(array($this->context))->getMock(); $manager->expects($this->once())->method('getCache')->will($this->returnValue($this->mock)); $name = 'MAdminCacheProxyDefaultTest'; $this->context->getConfig()->set('madmin/cache/manager/name', $name); \Aimeos\MAdmin\Cache\Manager\Factory::injectManager('\\Aimeos\\MAdmin\\Cache\\Manager\\' . $name, $manager); $this->object = new \Aimeos\MAdmin\Cache\Proxy\Standard($this->context); }
protected function setUp() { $this->context = \TestHelperMShop::getContext('unitperf'); $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); $search = $productManager->createSearch(); $search->setSlice(0, 1); $result = $productManager->searchItems($search, array('text', 'media', 'price', 'product', 'attribute')); if (($this->item = reset($result)) === false) { throw new \RuntimeException('No product item found'); } }
protected function setUp() { $this->context = \TestHelperMShop::getContext(); $servManager = \Aimeos\MShop\Service\Manager\Factory::createManager($this->context); $search = $servManager->createSearch(); $search->setConditions($search->compare('==', 'service.provider', 'Standard')); $result = $servManager->searchItems($search, array('price')); if (($item = reset($result)) === false) { throw new \Exception('No order base item found'); } $this->object = new TestBase($this->context, $item); }
protected function setUp() { $this->context = \TestHelperMShop::getContext(); $servManager = \Aimeos\MShop\Service\Manager\Factory::createManager($this->context); $search = $servManager->createSearch(); $search->setConditions($search->compare('==', 'service.provider', 'Standard')); $result = $servManager->searchItems($search, array('price')); if (($item = reset($result)) === false) { throw new \RuntimeException('No order base item found'); } $this->mock = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Payment\\PrePay')->setConstructorArgs(array($this->context, $item))->setMethods(array('calcPrice', 'checkConfigBE', 'checkConfigFE', 'getConfigBE', 'getConfigFE', 'injectGlobalConfigBE', 'isAvailable', 'isImplemented', 'query', 'cancel', 'capture', 'process', 'refund', 'setCommunication', 'setConfigFE', 'updateAsync', 'updateSync'))->getMock(); $this->object = new TestBase($this->mock, $this->context, $item); }
public function testUpdateAddressesAvailable() { $object = new \Aimeos\MShop\Plugin\Provider\Order\AddressesAvailable(\TestHelperMShop::getContext(), $this->plugin); $this->order->setAddress($this->address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); $this->order->setAddress($this->address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); $this->plugin->setConfig(array(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY => null, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT => null)); $this->assertTrue($object->update($this->order, 'check.after', \Aimeos\MShop\Order\Item\Base\Base::PARTS_ADDRESS)); $this->plugin->setConfig(array(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY => true, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT => true)); $this->assertTrue($object->update($this->order, 'check.after', \Aimeos\MShop\Order\Item\Base\Base::PARTS_ADDRESS)); $this->plugin->setConfig(array(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY => false, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT => false)); $this->setExpectedException('\\Aimeos\\MShop\\Plugin\\Provider\\Exception'); $object->update($this->order, 'check.after', \Aimeos\MShop\Order\Item\Base\Base::PARTS_ADDRESS); }
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())); }