/**
  * 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 = MShop_Order_Manager_Factory::createManager(TestHelper::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 = MShop_Plugin_Manager_Factory::createManager(TestHelper::getContext());
     $plugin = $pluginManager->createItem();
     $plugin->setTypeId(2);
     $plugin->setProvider('BasketLimits');
     $plugin->setConfig($config);
     $plugin->setStatus('1');
     $this->_object = new MShop_Plugin_Provider_Order_BasketLimits(TestHelper::getContext(), $plugin);
 }
Beispiel #2
0
 /**
  * Initializes the Order base service controller.
  *
  * @param MShop_Context_Item_Interface $context MShop context object
  */
 public function __construct(MShop_Context_Item_Interface $context)
 {
     parent::__construct($context, 'Order_Base_Service');
     $manager = MShop_Order_Manager_Factory::createManager($context);
     $baseManager = $manager->getSubManager('base');
     $this->_manager = $baseManager->getSubManager('service');
 }
 /**
  * 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 = MShop_Plugin_Manager_Factory::createManager($context);
     $this->_plugin = $pluginManager->createItem();
     $this->_plugin->setProvider('ProductGone');
     $this->_plugin->setStatus(1);
     $this->_orderManager = 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 = 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;
 }
Beispiel #4
0
 public function testCreateManagerNotExisting()
 {
     $this->setExpectedException('MShop_Exception');
     $target = 'MShop_Common_Manager_Interface';
     $manager = MShop_Order_Manager_Factory::createManager(TestHelper::getContext(), 'test');
     $this->assertInstanceOf($target, $manager);
 }
 /**
  * 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 = MShop_Plugin_Manager_Factory::createManager(TestHelper::getContext());
     $this->_plugin = $pluginManager->createItem();
     $this->_plugin->setTypeId(2);
     $this->_plugin->setProvider('PropertyMatch');
     $this->_plugin->setConfig(array('product.suppliercode' => 'unitSupplier'));
     $this->_plugin->setStatus('1');
     $orderManager = MShop_Order_Manager_Factory::createManager(TestHelper::getContext());
     $orderBaseManager = $orderManager->getSubManager('base');
     $orderBaseProductManager = $orderBaseManager->getSubManager('product');
     $manager = 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 MShop_Plugin_Provider_Order_PropertyMatch(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();
     $couponManager = MShop_Coupon_Manager_Factory::createManager($context);
     $this->_couponItem = $couponManager->createItem();
     $provider = new MShop_Coupon_Provider_Example($context, $this->_couponItem, 'abcd');
     $this->_object = new MShop_Coupon_Provider_Decorator_BasketValues($context, $this->_couponItem, 'abcd', $provider);
     $this->_object->setObject($this->_object);
     $orderManager = MShop_Order_Manager_Factory::createManager($context);
     $orderBaseManager = $orderManager->getSubManager('base');
     $orderProductManager = $orderBaseManager->getSubManager('product');
     $productManager = MShop_Product_Manager_Factory::createManager($context);
     $search = $productManager->createSearch();
     $search->setConditions($search->compare('==', 'product.code', array('CNC')));
     $products = $productManager->searchItems($search);
     $priceManager = 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 MShop_Order_Item_Base_Default($priceManager->createItem(), $context->getLocale());
     $this->_orderBase->addProduct($orderProducts['CNC']);
 }
 /**
  * Adds order test data.
  */
 protected function _process()
 {
     $iface = 'MShop_Context_Item_Interface';
     if (!$this->_additional instanceof $iface) {
         throw new 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 = MShop_Locale_Manager_Factory::createManager($this->_additional, 'Default');
     $orderManager = MShop_Order_Manager_Factory::createManager($this->_additional, 'Default');
     $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 = dirname(__FILE__) . $ds . 'data' . $ds . 'order.php';
     if (($testdata = (include $path)) == false) {
         throw new 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');
 }
Beispiel #8
0
 public function testProcess()
 {
     $manager = MShop_Order_Manager_Factory::createManager(TestHelper::getContext());
     $order = $manager->createItem();
     $this->_object->process($order);
     $this->assertEquals(MShop_Order_Item_Abstract::STAT_PROGRESS, $order->getDeliveryStatus());
 }
Beispiel #9
0
 /**
  * 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 = MShop_Order_Manager_Factory::createManager($this->_context);
     $this->_object = $orderManager->getSubManager('base')->getSubManager('address');
 }
Beispiel #10
0
 public function testSaveDeleteItem()
 {
     $manager = 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']));
 }
Beispiel #11
0
 public function testSaveDeleteItem()
 {
     $manager = 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 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']));
 }
Beispiel #12
0
 public function testProcessOK()
 {
     $controller = Controller_Frontend_Basket_Factory::createController($this->_context);
     $baseManager = MShop_Order_Manager_Factory::createManager($this->_context)->getSubManager('base');
     $serviceManager = 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 MW_View_Helper_Parameter_Default($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('MShop_Order_Item_Interface', $view->orderItem);
     $this->assertEquals($item->getId(), $view->orderItem->getBaseId());
 }
Beispiel #13
0
 public function testSaveDeleteItem()
 {
     $manager = 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']));
 }
Beispiel #14
0
 public function testCancel()
 {
     $manager = MShop_Order_Manager_Factory::createManager(TestHelper::getContext());
     $orderItem = $manager->createItem();
     $this->_object->cancel($orderItem);
     $this->assertEquals(MShop_Order_Item_Abstract::PAY_CANCELED, $orderItem->getPaymentStatus());
 }
Beispiel #15
0
 /**
  * Initializes the order base service attribute controller.
  *
  * @param MShop_Context_Item_Interface $context MShop context object
  */
 public function __construct(MShop_Context_Item_Interface $context)
 {
     parent::__construct($context, 'Order_Base_Product_Attribute');
     $manager = MShop_Order_Manager_Factory::createManager($context);
     $baseManager = $manager->getSubManager('base');
     $productManager = $baseManager->getSubManager('product');
     $this->_manager = $productManager->getSubManager('attribute');
 }
Beispiel #16
0
 public function testSaveDeleteItem()
 {
     $ctx = TestHelper::getContext();
     $localeManager = 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 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 = 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' => MShop_Common_Item_Address_Abstract::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.metaways.de'));
     $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 = MShop_Factory::createManager($this->_context, 'service');
     $this->_servItem = $servManager->createItem();
     $this->_mockProvider = $this->getMockBuilder('MShop_Service_Provider_Decorator_Reduction')->disableOriginalConstructor()->getMock();
     $this->_basket = MShop_Order_Manager_Factory::createManager($this->_context)->getSubManager('base')->createItem();
     $this->_object = new MShop_Service_Provider_Decorator_Reduction($this->_context, $this->_servItem, $this->_mockProvider);
 }
Beispiel #18
0
 /**
  * @param string $date
  */
 protected function _getOrder($date)
 {
     $orderManager = 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;
 }
Beispiel #19
0
 public static function setUpBeforeClass()
 {
     $orderManager = 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());
 }
Beispiel #20
0
 protected function _getOrderItem($customerid)
 {
     $manager = 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;
 }
 /**
  * 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 = MShop_Plugin_Manager_Factory::createManager($context);
     $this->_plugin = $pluginManager->createItem();
     $this->_plugin->setProvider('ServicesAvailable');
     $this->_plugin->setStatus(1);
     $orderBaseManager = MShop_Order_Manager_Factory::createManager($context)->getSubManager('base');
     $orderBaseServiceManager = $orderBaseManager->getSubManager('service');
     $this->_order = $orderBaseManager->createItem();
     $this->_service = $orderBaseServiceManager->createItem();
 }
 /**
  * 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 = MShop_Plugin_Manager_Factory::createManager($context);
     $this->_plugin = $pluginManager->createItem();
     $this->_plugin->setProvider('AddressesAvailable');
     $this->_plugin->setStatus(1);
     $orderBaseManager = MShop_Order_Manager_Factory::createManager($context)->getSubManager('base');
     $orderBaseAddressManager = $orderBaseManager->getSubManager('address');
     $this->_order = $orderBaseManager->createItem();
     $this->_address = $orderBaseAddressManager->createItem();
     $this->_address->setLastName('Available');
 }
 public function testUpdateAttributeExists()
 {
     $attributeManager = MShop_Order_Manager_Factory::createManager(TestHelper::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()));
 }
Beispiel #24
0
 /**
  * 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 = MShop_Plugin_Manager_Factory::createManager($context);
     $plugin = $pluginManager->createItem();
     $plugin->setTypeId(2);
     $plugin->setProvider('Shipping');
     $plugin->setConfig(array('threshold' => array('EUR' => '34.00')));
     $plugin->setStatus('1');
     $orderManager = MShop_Order_Manager_Factory::createManager($context);
     $orderBaseManager = $orderManager->getSubManager('base');
     $orderBaseProductManager = $orderBaseManager->getSubManager('product');
     $manager = 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 Exception('Wrong number of products');
     }
     $products = array();
     foreach ($pResults as $prod) {
         $products[$prod->getCode()] = $prod;
     }
     if (($price = current($products['IJKL']->getRefItems('price'))) === false) {
         throw new Exception('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 Exception('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 MShop_Plugin_Provider_Order_Shipping($context, $plugin);
 }
Beispiel #25
0
 public function testGetBody()
 {
     $manager = 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 = TestHelper::getView();
     $view->confirmOrderItem = $item;
     $this->_object->setView($view);
     $output = $this->_object->getBody();
     $this->assertStringStartsWith('<div class="checkout-confirm-intro">', $output);
 }
Beispiel #26
0
 public function testRunException()
 {
     $context = TestHelper::getContext();
     $arcavias = TestHelper::getArcavias();
     $mailStub = $this->getMockBuilder('MW_Mail_None')->disableOriginalConstructor()->getMock();
     $context->setMail($mailStub);
     $name = 'ControllerJobsEmailDeliveryDefaultRun';
     $context->getConfig()->set('classes/order/manager/name', $name);
     $orderManagerStub = $this->getMockBuilder('MShop_Order_Manager_Default')->setMethods(array('searchItems'))->setConstructorArgs(array($context))->getMock();
     MShop_Order_Manager_Factory::injectManager('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 Controller_Jobs_Order_Email_Delivery_Default($context, $arcavias);
     $object->run();
 }
Beispiel #27
0
 public function testStore()
 {
     $context = TestHelper::getContext();
     $name = 'ControllerFrontendOrderStore';
     $context->getConfig()->set('classes/order/manager/name', $name);
     $orderManagerStub = $this->getMockBuilder('MShop_Order_Manager_Default')->setMethods(array('saveItem', 'getSubManager'))->setConstructorArgs(array($context))->getMock();
     $orderBaseManagerStub = $this->getMockBuilder('MShop_Order_Manager_Base_Default')->setMethods(array('store'))->setConstructorArgs(array($context))->getMock();
     MShop_Order_Manager_Factory::injectManager('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 Controller_Frontend_Order_Default($context);
     $object->store($orderBaseItem);
 }
Beispiel #28
0
 public function testUpdate()
 {
     $context = TestHelper::getContext();
     $config = $context->getConfig();
     $name = 'ControllerCommonOrderBlock';
     $config->set('classes/order/manager/name', $name);
     $config->set('classes/product/manager/name', $name);
     $config->set('classes/coupon/manager/name', $name);
     $orderManagerStub = $this->getMockBuilder('MShop_Order_Manager_Default')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
     $orderBaseManagerStub = $this->getMockBuilder('MShop_Order_Manager_Base_Default')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
     $orderStatusManagerStub = $this->getMockBuilder('MShop_Order_Manager_Status_Default')->setMethods(array('saveItem', 'searchItems'))->setConstructorArgs(array($context))->getMock();
     $orderProductManagerStub = $this->getMockBuilder('MShop_Order_Manager_Base_Product_Default')->setMethods(array('searchItems'))->setConstructorArgs(array($context))->getMock();
     $orderCouponManagerStub = $this->getMockBuilder('MShop_Order_Manager_Base_Coupon_Default')->setMethods(array('searchItems'))->setConstructorArgs(array($context))->getMock();
     $productManagerStub = $this->getMockBuilder('MShop_Product_Manager_Default')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
     $productStockManagerStub = $this->getMockBuilder('MShop_Product_Manager_Stock_Default')->setMethods(array('increase'))->setConstructorArgs(array($context))->getMock();
     $couponManagerStub = $this->getMockBuilder('MShop_Coupon_Manager_Default')->setMethods(array('getSubManager'))->setConstructorArgs(array($context))->getMock();
     $couponCodeManagerStub = $this->getMockBuilder('MShop_Coupon_Manager_Code_Default')->setMethods(array('increase'))->setConstructorArgs(array($context))->getMock();
     MShop_Order_Manager_Factory::injectManager('MShop_Order_Manager_' . $name, $orderManagerStub);
     MShop_Order_Manager_Factory::injectManager('MShop_Product_Manager_' . $name, $productManagerStub);
     MShop_Order_Manager_Factory::injectManager('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(2))->method('getSubManager')->will($this->returnValue($productStockManagerStub));
     $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(MShop_Order_Item_Abstract::PAY_UNFINISHED);
     $object = new Controller_Common_Order_Default($context);
     $object->update($orderItem);
     $orderItem = $orderManagerStub->createItem();
     $orderItem->setPaymentStatus(MShop_Order_Item_Abstract::PAY_PENDING);
     $object = new Controller_Common_Order_Default($context);
     $object->update($orderItem);
     $orderItem = $orderManagerStub->createItem();
     $orderItem->setPaymentStatus(MShop_Order_Item_Abstract::PAY_DELETED);
     $object = new Controller_Common_Order_Default($context);
     $object->update($orderItem);
 }
Beispiel #29
0
 public function testRun()
 {
     $context = TestHelper::getContext();
     $arcavias = TestHelper::getArcavias();
     $name = 'ControllerJobsOrderCleanupUnpaidDefaultRun';
     $context->getConfig()->set('classes/order/manager/name', $name);
     $orderManagerStub = $this->getMockBuilder('MShop_Order_Manager_Default')->setMethods(array('searchItems', 'getSubManager'))->setConstructorArgs(array($context))->getMock();
     $orderBaseManagerStub = $this->getMockBuilder('MShop_Order_Manager_Base_Default')->setMethods(array('deleteItems'))->setConstructorArgs(array($context))->getMock();
     MShop_Order_Manager_Factory::injectManager('MShop_Order_Manager_' . $name, $orderManagerStub);
     $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');
     $object = new Controller_Jobs_Order_Cleanup_Unpaid_Default($context, $arcavias);
     $object->run();
 }
 /**
  * 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();
     $couponItem = MShop_Coupon_Manager_Factory::createManager($context)->createItem();
     $couponItem->setConfig(array('freeshipping.productcode' => 'U:SD'));
     $this->_object = new MShop_Coupon_Provider_FreeShipping($context, $couponItem, 'zyxw');
     $delPrice = MShop_Price_Manager_Factory::createManager($context)->createItem();
     $delPrice->setCosts('5.00');
     $delPrice->setCurrencyId('EUR');
     $priceManager = MShop_Price_Manager_Factory::createManager($context);
     $manager = 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 MShop_Order_Item_Base_Default($priceManager->createItem(), $context->getLocale());
     $this->_orderBase->setService($delivery, 'delivery');
 }