本文整理汇总了PHP中MShop_Order_Manager_Factory类的典型用法代码示例。如果您正苦于以下问题:PHP MShop_Order_Manager_Factory类的具体用法?PHP MShop_Order_Manager_Factory怎么用?PHP MShop_Order_Manager_Factory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MShop_Order_Manager_Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* 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);
}
示例2: __construct
/**
* 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');
}
示例3: setUp
/**
* 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;
}
示例4: testCreateManagerNotExisting
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);
}
示例5: setUp
/**
* 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);
}
示例6: setUp
/**
* 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']);
}
示例7: _process
/**
* 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');
}
示例8: testProcess
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());
}
示例9: setUp
/**
* 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');
}
示例10: testSaveDeleteItem
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']));
}
示例11: testSaveDeleteItem
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']));
}
示例12: testProcessOK
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());
}
示例13: testSaveDeleteItem
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']));
}
示例14: testCancel
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());
}
示例15: __construct
/**
* 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');
}