本文整理汇总了PHP中EcomDev_Utils_Reflection::setRestrictedPropertyValues方法的典型用法代码示例。如果您正苦于以下问题:PHP EcomDev_Utils_Reflection::setRestrictedPropertyValues方法的具体用法?PHP EcomDev_Utils_Reflection::setRestrictedPropertyValues怎么用?PHP EcomDev_Utils_Reflection::setRestrictedPropertyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EcomDev_Utils_Reflection
的用法示例。
在下文中一共展示了EcomDev_Utils_Reflection::setRestrictedPropertyValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _handleScopeRow
/**
* Handle scope row data
*
* @param string $type
* @param array $row
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return boolean|Mage_Core_Model_Abstract
*/
protected function _handleScopeRow($type, $row, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$previousScope = array();
if ($fixture->isScopeLocal() && $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED) !== null) {
$previousScope = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
}
if (isset($previousScope[$type][$row[$type . '_id']])) {
return false;
}
$scopeModel = Mage::getModel($this->modelByType[$type]);
$scopeModel->setData($row);
// Change property for saving new objects with specified ids
EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => false));
try {
$scopeModel->isObjectNew(true);
$scopeModel->save();
} catch (Exception $e) {
Mage::logException($e);
// Skip duplicated key violation, since it might be a problem
// of previous run with fatal error
// Revert changed property
EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => true));
// Load to make possible deletion
$scopeModel->load($row[$type . '_id']);
}
// Revert changed property
EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => true));
return $scopeModel;
}
示例2: setUp
public function setUp()
{
$logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']);
$logContext->expects($this->any())->method('getMetaData')->will($this->returnValue([]));
$this->_api = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Api\\IBidirectionalApi');
// Create two request bodies - one to serve as the "empty" request
// body that needs to be populated with data and one to serve as
// the "complete" payload that has been populated with data.
$this->_emptyRequestBody = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\TaxDutyFee\\ITaxDutyFeeQuoteRequest');
$this->_completeRequestBody = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\TaxDutyFee\\ITaxDutyFeeQuoteRequest');
$this->_responseBody = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\TaxDutyFee\\ITaxDutyFeeQuoteReply');
$this->_coreHelper = $this->getHelperMock('ebayenterprise_eb2ccore', ['getSdkApi']);
$this->_taxConfig = $this->buildCoreConfigRegistry(['apiService' => $this->_apiService, 'apiOperation' => $this->_apiOperation]);
$this->_taxHelper = $this->getHelperMock('ebayenterprise_tax/data', ['__']);
$this->_taxHelper->expects($this->any())->method('__')->will($this->returnArgument(0));
$this->_taxFactory = $this->getHelperMock('ebayenterprise_tax/factory', ['createRequestBuilderQuote', 'createResponseQuoteParser', 'createTaxResults']);
$this->_quoteRequestBuilder = $this->getModelMockBuilder('ebayenterprise_tax/request_builder_quote')->disableOriginalConstructor()->setMethods(['getTaxRequest'])->getMock();
$this->_quoteResponseParser = $this->getModelMockBuilder('ebayenterprise_tax/response_parser_quote')->disableOriginalConstructor()->setMethods(['getTaxRecords', 'getTaxDuties', 'getTaxFees'])->getMock();
$this->_quote = $this->getModelMock('sales/quote');
$this->_taxHelper = $this->getHelperMock('ebayenterprise_tax', ['getConfigModel']);
$this->_taxHelper->method('getConfigModel')->willReturn($this->_taxConfig);
// As helpers do not support constructor injection, inject
// dependencies by directly setting the class properties.
EcomDev_Utils_Reflection::setRestrictedPropertyValues($this->_taxHelper, ['coreHelper' => $this->_coreHelper, 'taxFactory' => $this->_taxFactory, 'logContext' => $logContext]);
}
示例3: testGetCookiesString
/**
* verify the cookie array is converted to a string
* @dataProvider provideCookieArray
*/
public function testGetCookiesString(array $arr, $expected)
{
$helper = Mage::helper('eb2cfraud/http');
EcomDev_Utils_Reflection::setRestrictedPropertyValues($helper, ['_request' => $this->_requestStub, '_cookie' => $this->_cookieStub]);
$this->_cookieStub->expects($this->any())->method('get')->will($this->returnValue($arr));
$this->assertSame($expected, $helper->getCookiesString());
}
示例4: testGetTrackingData
/**
* Scenario: Get tracking data
* Given a ROM order object
* And shipment id
* And tracking number
* When getting tracking data
* Then get the specified shipment from the ROM order object
* And extract tracking data for it.
*
* @param Mage_Sales_Model_Order
* @param EbayEnterprise_Order_Model_Detail_Process_Response_Shipment
* @param string
* @param string
* @dataProvider providerTrackingInfo
*/
public function testGetTrackingData(Mage_Sales_Model_Order $order, EbayEnterprise_Order_Model_Detail_Process_Response_Shipment $shipment, $shipmentId, $trackingNumber)
{
/** @var Varien_Data_Collection */
$shipments = new Varien_Data_Collection();
$shipments->addItem($shipment);
EcomDev_Utils_Reflection::setRestrictedPropertyValues($order, ['_shipments' => $shipments]);
/** @var EbayEnterprise_Order_Model_Tracking */
$tracking = $this->getModelMock('ebayenterprise_order/tracking', ['extractTrackingDataFromShipment'], false, [['order' => $order, 'shipment_id' => $shipmentId, 'tracking_number' => $trackingNumber]]);
$tracking->expects($this->once())->method('extractTrackingDataFromShipment')->with($this->identicalTo($shipment))->will($this->returnValue([]));
$this->assertCount(1, $tracking->getTrackingData());
}
示例5: testInjectShippingOriginForItem
public function testInjectShippingOriginForItem()
{
$detail = $this->getModelMockBuilder('ebayenterprise_inventory/details_item')->disableOriginalConstructor()->setMethods(null)->getMock();
EcomDev_Utils_Reflection::setRestrictedPropertyValues($detail, ['isAvailable' => true, 'shipFromLines' => 'shipFromLines', 'shipFromCity' => 'shipFromCity', 'shipFromMainDivision' => 'shipFromMainDivision', 'shipFromCountryCode' => 'shipFromCountryCode', 'shipFromPostalCode' => 'shipFromPostalCode']);
$item = $this->getModelMock('sales/quote_item', ['getId']);
$item->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->detailsService = $this->getModelMockBuilder('ebayenterprise_inventory/details_service')->disableOriginalConstructor()->setMethods(['getDetailsForItem'])->getMock();
$this->detailsService->expects($this->any())->method('getDetailsForItem')->with($this->identicalTo($item))->will($this->returnValue($detail));
$address = $this->getModelMockBuilder('customer/address_abstract')->disableOriginalConstructor()->setMethods(['addData'])->getMockForAbstractClass();
$address->expects($this->once())->method('addData')->with($this->equalTo(['street' => 'shipFromLines', 'city' => 'shipFromCity', 'region_code' => 'shipFromMainDivision', 'country_id' => 'shipFromCountryCode', 'postcode' => 'shipFromPostalCode']))->will($this->returnSelf());
$origin = Mage::getModel('ebayenterprise_inventory/tax_shipping_origin', ['details_service' => $this->detailsService, 'logger' => $this->logger, 'log_context' => $this->logContext]);
$origin->injectShippingOriginForItem($item, $address);
}
示例6: setUp
public function setUp()
{
parent::setUp();
$this->payload = $this->mockPayload();
$detail = $this->getModelMockBuilder('ebayenterprise_inventory/details_item')->disableOriginalConstructor()->setMethods(null)->getMock();
EcomDev_Utils_Reflection::setRestrictedPropertyValues($detail, ['isAvailable' => true, 'deliveryWindowFromDate' => new DateTime(), 'deliveryWindowToDate' => null, 'shippingWindowFromDate' => null, 'shippingWindowToDate' => null]);
$config = $this->buildCoreConfigRegistry(['estimatedDeliveryTemplate' => 'eddtemplate']);
$this->helperStub = $this->getHelperMockBuilder('ebayenterprise_inventory/data')->disableOriginalConstructor()->setMethods(['getConfigModel'])->getMock();
$this->helperStub->expects($this->any())->method('getConfigModel')->will($this->returnValue($config));
$this->item = Mage::getModel('sales/order_item');
$this->detailService = $this->getModelMockBuilder('ebayenterprise_inventory/details_service')->disableOriginalConstructor()->setMethods(['getDetailsForOrderItem'])->getMock();
$this->detailService->expects($this->once())->method('getDetailsForOrderItem')->will($this->returnValue($detail));
$this->order = Mage::getModel('sales/order');
}
示例7: setUp
public function setUp()
{
$logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']);
$logContext->expects($this->any())->method('getMetaData')->will($this->returnValue([]));
$this->_api = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Api\\IBidirectionalApi');
// Create two request bodies - one to serve as the "empty" request
// body that needs to be populated with data and one to serve as
// the "complete" payload that has been populated with data.
$this->_emptyRequestBody = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IQuantityRequest');
$this->_completeRequestBody = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IQuantityRequest');
$this->_responseBody = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IQuantityReply');
$this->_coreHelper = $this->getHelperMock('ebayenterprise_eb2ccore', ['getSdkApi']);
$this->_inventoryConfig = $this->buildCoreConfigRegistry(['apiService' => $this->_apiService, 'quantityApiOperation' => $this->_apiOperation]);
$this->_inventoryHelper = $this->getHelperMock('ebayenterprise_inventory/data', ['__']);
$this->_inventoryHelper->expects($this->any())->method('__')->will($this->returnArgument(0));
$this->_inventoryFactory = $this->getHelperMock('ebayenterprise_inventory/quantity_factory', ['createRequestBuilder', 'createResponseParser', 'createQuantityResults']);
$this->_requestBuilder = $this->getModelMockBuilder('ebayenterprise_inventory/quantity_request_builder')->disableOriginalConstructor()->setMethods(['getRequest'])->getMock();
$this->_responseParser = $this->getModelMockBuilder('ebayenterprise_inventory/quantity_response_parser')->disableOriginalConstructor()->setMethods(['getQuantityResults'])->getMock();
$this->_items = [$this->getModelMock('sales/quote_item')];
$this->_sdkHelper = Mage::helper('ebayenterprise_inventory/quantity_sdk');
// As helpers do not support constructor injection, inject
// dependencies by directly setting the class properties.
EcomDev_Utils_Reflection::setRestrictedPropertyValues($this->_sdkHelper, ['_coreHelper' => $this->_coreHelper, '_inventoryHelper' => $this->_inventoryHelper, '_inventoryConfig' => $this->_inventoryConfig, '_logContext' => $logContext, '_inventoryQuantityFactory' => $this->_inventoryFactory]);
}
示例8: testGatherBatchesUsesDefaultWebsiteWhenNoOthersExist
/**
* verify the default website is use when no other websites are
* available.
*/
public function testGatherBatchesUsesDefaultWebsiteWhenNoOthersExist()
{
$websites = array(0 => $this->_defaultWebsite);
EcomDev_Utils_Reflection::setRestrictedPropertyValues(Mage::app(), array('_websites' => $websites));
$this->replaceByMock('helper', 'eb2ccore/languages', $this->_languageHelper);
$priceCollector = Mage::getModel('ebayenterprise_catalog/pim_collector_price');
$this->replaceByMock('resource_model', 'catalog/product_collection', $this->_collectionDefault);
$this->_batchContainer->expects($this->once())->method('addBatch')->with($this->identicalTo($this->_collectionDefault), $this->identicalTo(array()), $this->identicalTo($this->_feedConfig), $this->identicalTo($this->_defaultStore))->will($this->returnSelf());
$priceCollector->gatherBatches($this->_eventObserver);
}
示例9: testGuestOrderViewAction
/**
* Test that the controller method EbayEnterprise_Order_GuestController::_viewAction()
* is invoked and it will call the method EbayEnterprise_Order_GuestController::getRequest()
* which will return an instance of an object of type Zend_Controller_Request_Http class.
* Then, the method Zend_Controller_Request_Abstract::getPost() will be invoked 4 time. In the first
* called it will be passed the string literal 'oar_order_id' and we expect an order id to return. In the second
* called it will be passed the string literal 'oar_email' and we expect an email address string to be returned.
* In the third called it will be passed the string literal 'oar_zip' and we expect a zip code string to be returned.
* In the fourth called it will be passed the string literal 'oar_billing_lastname' and we expect a last name string to be returned.
* Then, the method ebayenterprise_order/factory::getCoreSessionModel() will be invoked and return an object of type core/session. Then, the method
* ebayenterprise_order/factory::getNewRomOrderDetailModel() will be invoked and return an object of type ebayenterprise_order/detail. Then, the method
* ebayenterprise_order/detail::process() will be called passing in the order id from post. If no exception is thrown, then, the method
* EbayEnterprise_Order_GuestController::_hasValidOrderResult() will be invoked and passed in as first parameter
* the ebayenterprise_order/detail_process_response object, as second parameter the email address, as third parameter the zip code, and
* as fourth parameter the last name. If the return value from calling the method EbayEnterprise_Order_GuestController::_hasValidOrderResult()
* is true, then, the method EbayEnterprise_Order_GuestController::_redirect() will be invoked and passed in as first parameter a string literal
* representing URI path, and as second parameter an array with key 'order_id' mapped to the order id.
* However, if the method EbayEnterprise_Order_GuestController::_hasValidOrderResult() return false, then,
* the method core/session::addError() will be called and passed in the return value from calling the method
* ebayenterprise_order/data::__() and passed in the string literal 'Order not found'. Then, the method
* EbayEnterprise_Order_GuestController::_redirect() will be called and passed in the string literal 'sales/guest/form'.
* If an exception was thrown, then, the method core/session::addError() will be called and passed in the return value from
* calling the method EbayEnterprise_Order_Exception_Order_Detail_Notfound_Exception::getMessage(). Then, the method
* EbayEnterprise_Order_GuestController::_redirect() will be called and passed in the string literal 'sales/guest/form'.
* Finally, the method EbayEnterprise_Order_GuestController::_viewAction() will return null.
*
* @param bool
* @param bool
* @dataProvider providerViewAction
*/
public function testGuestOrderViewAction($isException, $isValidOrder)
{
/** @var bool */
$isError = $isException | !$isValidOrder;
/** @var string */
$message = 'Exception test message';
/** @var EbayEnterprise_Order_Exception_Order_Detail_Notfound_Exception | null */
$exception = $isException ? Mage::exception('EbayEnterprise_Order_Exception_Order_Detail_Notfound', $message) : null;
/** @var null */
$default = null;
/** @var string */
$orderId = '10000093888341';
/** @var string */
$email = 'test@test.example.com';
/** @var string */
$zip = '19063';
/** @var string */
$lastname = 'Doe';
/** @var string */
$guestFormUrl = 'sales/guest/form';
/** @var string */
$orderDetailUrl = 'sales/order/romguestview';
/** @var string */
$errorMessage = 'Order not found.';
/** @var string */
$translatedErrorMessage = $errorMessage;
/** @var Mock_Zend_Controller_Request_Http */
$request = $this->getMock('Zend_Controller_Request_Http', ['getPost']);
$request->expects($this->exactly(4))->method('getPost')->will($this->returnValueMap([['oar_order_id', $default, $orderId], ['oar_email', $default, $email], ['oar_zip', $default, $zip], ['oar_billing_lastname', $default, $lastname]]));
/** @var Mock_Mage_Core_Model_Session */
$session = $this->getModelMockBuilder('core/session')->disableOriginalConstructor()->setMethods(['addError'])->getMock();
$session->expects($isError ? $this->once() : $this->never())->method('addError')->will($this->returnValueMap([[$message, $session], [$translatedErrorMessage, $session]]));
/** @var EbayEnterprise_Order_Helper_Data */
$helper = $this->getHelperMock('ebayenterprise_order/data', ['__']);
$helper->expects($isValidOrder ? $this->never() : $this->once())->method('__')->with($this->identicalTo($errorMessage))->will($this->returnValue($translatedErrorMessage));
/** @var EbayEnterprise_Order_Model_Detail_Process_Response */
$response = $this->getModelMockBuilder('ebayenterprise_order/detail_process_response')->disableOriginalConstructor()->getMock();
/** @var Mock_EbayEnterprise_Order_Model_Detail */
$orderDetail = $this->getModelMockBuilder('ebayenterprise_order/detail')->disableOriginalConstructor()->getMock();
$orderDetail->expects($this->once())->method('process')->will($isException ? $this->throwException($exception) : $this->returnValue($response));
/** @var EbayEnterprise_Order_Helper_Factory */
$factory = $this->getHelperMock('ebayenterprise_order/factory', ['getCoreSessionModel', 'getNewRomOrderDetailModel']);
$factory->expects($this->once())->method('getCoreSessionModel')->will($this->returnValue($session));
$factory->expects($this->once())->method('getNewRomOrderDetailModel')->with($this->identicalTo($orderId))->will($this->returnValue($orderDetail));
/** @var Mock_EbayEnterprise_Order_GuestController */
$controller = $this->getMockBuilder('EbayEnterprise_Order_GuestController')->setMethods(['getRequest', '_redirect', '_hasValidOrderResult'])->setConstructorArgs([$request, $this->_response])->getMock();
EcomDev_Utils_Reflection::setRestrictedPropertyValues($controller, ['_orderFactory' => $factory, '_orderHelper' => $helper]);
$controller->expects($this->once())->method('getRequest')->will($this->returnValue($request));
$controller->expects($this->once())->method('_redirect')->will($this->returnValueMap([[$guestFormUrl, [], $controller], [$orderDetailUrl, ['order_id' => $orderId], $controller]]));
$controller->expects($isException ? $this->never() : $this->once())->method('_hasValidOrderResult')->with($this->identicalTo($response), $this->identicalTo($email), $this->identicalTo($zip), $this->identicalTo($lastname))->will($this->returnValue($isValidOrder));
$this->assertNull($controller->viewAction());
}
示例10: testDisplayPage
/**
* Test that the controller method EbayEnterprise_Order_OrderController::_displayPage()
* is invoked and it will call the method EbayEnterprise_Order_OrderController::loadLayout() will be invoked. Then,
* the method EbayEnterprise_Order_OrderController::_initLayoutMessages() will be called and passed
* in as parameter the string literal 'catalog/session'. Then, the method EbayEnterprise_Order_OrderController::getLayout()
* will be called and return an instance of the class Mage_Core_Model_Layout. Then,
* the method Mage_Core_Model_Layout::getBlock() will be called and passed in as parameter the string
* literal 'customer_account_navigation' and it will return an instance object that extend the abstract class
* Mage_Core_Block_Abstract. Then, the method Mage_Core_Block_Abstract::setActive() will be called. Then, the method
* EbayEnterprise_Order_OrderController::renderLayout() will be called. Finally, the method
* EbayEnterprise_Order_OrderController::romViewAction() will return null.
*/
public function testDisplayPage()
{
/** @var bool */
$isLoggedIn = true;
/** @var string */
$messages = 'catalog/session';
/** @var string */
$blockName = 'customer_account_navigation';
/** @var string */
$path = 'sales/order/history';
$this->_session->expects($this->once())->method('isLoggedIn')->will($this->returnValue($isLoggedIn));
/** @var EbayEnterprise_Order_Helper_Factory */
$factory = $this->getHelperMock('ebayenterprise_order/factory', ['getCustomerSession']);
$factory->expects($this->once())->method('getCustomerSession')->will($this->returnValue($this->_session));
/** @var Mage_Core_Block_Abstract */
$block = $this->getMockForAbstractClass('Mage_Core_Block_Abstract', [], '', true, true, true, ['setActive']);
$block->expects($this->once())->method('setActive')->with($this->identicalTo($path))->will($this->returnSelf());
/** @var Mage_Core_Model_Layout */
$layout = $this->getModelMock('core/layout', ['getBlock']);
$layout->expects($this->once())->method('getBlock')->with($this->identicalTo($blockName))->will($this->returnValue($block));
/** @var Mock_Zend_Controller_Request_Abstract */
$request = $this->getMockForAbstractClass('Zend_Controller_Request_Abstract');
/** @var Mock_Zend_Controller_Response_Abstract */
$response = $this->getMockForAbstractClass('Zend_Controller_Response_Abstract');
/** @var Mock_EbayEnterprise_Order_OrderController */
$controller = $this->getMockBuilder('EbayEnterprise_Order_OrderController')->setMethods(['loadLayout', '_initLayoutMessages', 'getLayout', 'renderLayout'])->setConstructorArgs([$request, $response])->getMock();
EcomDev_Utils_Reflection::setRestrictedPropertyValues($controller, ['_orderFactory' => $factory]);
$controller->expects($this->once())->method('loadLayout')->will($this->returnSelf());
$controller->expects($this->once())->method('_initLayoutMessages')->with($this->identicalTo($messages))->will($this->returnSelf());
$controller->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
$controller->expects($this->once())->method('renderLayout')->will($this->returnSelf());
$this->assertNull(EcomDev_Utils_Reflection::invokeRestrictedMethod($controller, '_displayPage', []));
}
示例11: testFormatPrice
/**
* Test that helper method ebayenterprise_order/data::formatPrice()
* when invoked will be passed in either string, float, and even null
* value and it will return an HTML price formatted string.
*
* @param string | null | float
* @dataProvider providerFormatPrice
*/
public function testFormatPrice($amount, $result)
{
/** @var Mage_Core_Helper_Data */
$coreHelper = Mage::helper('core');
/** @var Mage_Core_Model_Session */
$session = $this->getModelMock('core/session', ['init']);
$session->expects($this->any())->method('init')->will($this->returnSelf());
$this->replaceByMock('model', 'core/session', $session);
EcomDev_Utils_Reflection::setRestrictedPropertyValues($this->_recent, ['_coreHelper' => $coreHelper]);
$this->assertSame($result, $this->_recent->formatPrice($amount));
}
示例12: testRemoveFromWebsite
/**
* Test EbayEnterprise_Catalog_Model_Feed_File::_removeFromWebsites method for the following expectations
* Expectation 1: this test will invoked the method EbayEnterprise_Catalog_Model_Feed_File::_removeFromWebsites given
* a mocked Mage_Catalog_Model_Resource_Product_Collection object and an array of extracted data to be
* remove per for any given website.
* Expectation 2: the method EbayEnterprise_Catalog_Helper_Data::loadWebsiteFilter will be called which will return
* an array of websites with client id, catalog id and mage website id keys per webssites
* Expectation 3: the method EbayEnterprise_Catalog_Model_Feed_File::_getSkusInWebsite will be invoked given the array
* of skus data and an array of specific website data
* Expectation 4: the method Mage_Catalog_Model_Resource_Product_Collection::getItemById will then be invoked given
* a sku if the return value is an Mage_Catalog_Model_Product object it will call the method
* Mage_Catalog_Model_Product::getWebsites which will return an array of all website ids in this product
* this array will be pass as the first parameter to the method EbayEnterprise_Catalog_Model_Feed_File::_removeWebsiteId
* and a second parameter of the website data mage website id which will return an array excluding the website id
* that was pass it and this return array will be pass to the method Mage_Catalog_Model_Product::setWebsites method
* Expectation 5: last thing is the method Mage_Catalog_Model_Resource_Product_Collection::save will be inovked
*/
public function testRemoveFromWebsite()
{
$sku = '45-1334';
$dData = array($sku => array());
$websiteFilters = array(array('mage_website_id' => '1'), array('mage_website_id' => '2'));
$wIds = array('1', '2', '3');
$removedIds = array('2', '3');
$productMock = $this->getModelMockBuilder('catalog/product')->disableOriginalConstructor()->setMethods(array('getWebsiteIds', 'setWebsiteIds'))->getMock();
$productMock->expects($this->once())->method('getWebsiteIds')->will($this->returnValue($wIds));
$productMock->expects($this->once())->method('setWebsiteIds')->with($this->identicalTo($removedIds))->will($this->returnSelf());
$collectionMock = $this->getResourceModelMockBuilder('ebayenterprise_catalog/feed_product_collection')->disableOriginalConstructor()->setMethods(array('getItemById', 'save'))->getMock();
$collectionMock->expects($this->once())->method('getItemById')->with($this->identicalTo($sku))->will($this->returnValue($productMock));
$collectionMock->expects($this->once())->method('save')->will($this->returnSelf());
$helperMock = $this->getHelperMockBuilder('ebayenterprise_catalog/data')->disableOriginalConstructor()->setMethods(array('loadWebsiteFilters'))->getMock();
$helperMock->expects($this->once())->method('loadWebsiteFilters')->will($this->returnValue($websiteFilters));
$this->replaceByMock('helper', 'ebayenterprise_catalog', $helperMock);
$fileMock = $this->getModelMockBuilder('ebayenterprise_catalog/feed_file')->disableOriginalConstructor()->setMethods(array('_getSkusInWebsite', '_removeWebsiteId'))->getMock();
$fileMock->expects($this->exactly(2))->method('_getSkusInWebsite')->will($this->returnValueMap(array(array($dData, $websiteFilters[0], array($sku)), array($dData, $websiteFilters[1], array()))));
$fileMock->expects($this->once())->method('_removeWebsiteId')->with($this->identicalTo($wIds), $this->identicalTo($websiteFilters[0]['mage_website_id']))->will($this->returnValue($removedIds));
EcomDev_Utils_Reflection::setRestrictedPropertyValues($fileMock, array('_helper' => $helperMock));
$this->assertSame($fileMock, EcomDev_Utils_Reflection::invokeRestrictedMethod($fileMock, '_removeFromWebsites', array($collectionMock, $dData)));
}
示例13: testRomtrackingpopupAction
/**
* Scenario: Display shipment tracking information
* Given ROM order id
* And shipment id
* And tracking number
* When displaying shipment tracking information
* Then get ROM order detail in the registry
* And store a ebayenterprise_order/tracking instance in the registry
* And load and render the layout.
*/
public function testRomtrackingpopupAction()
{
/** @var string */
$shipmentId = 's0-000399399991111';
/** @var string */
$trackingNumber = '993999222';
/** @var Mage_Sales_Model_Order */
$order = Mage::getModel('sales/order');
Mage::unregister('rom_order');
Mage::register('rom_order', $order);
/** @var EbayEnterprise_Order_Model_Tracking */
$trackingModel = $this->getModelMockBuilder('ebayenterprise_order/tracking')->disableOriginalConstructor()->getMock();
/** @var EbayEnterprise_Order_Helper_Factory */
$factory = $this->getHelperMock('ebayenterprise_order/factory', ['getNewTrackingModel']);
$factory->expects($this->once())->method('getNewTrackingModel')->with($this->identicalTo($order), $this->identicalTo($shipmentId), $this->identicalTo($trackingNumber))->will($this->returnValue($trackingModel));
$this->_request->expects($this->exactly(2))->method('getParam')->will($this->returnValueMap([['shipment_id', null, $shipmentId], ['tracking_number', null, $trackingNumber]]));
$this->_controller->expects($this->once())->method('_loadValidOrder')->will($this->returnValue(true));
$this->_controller->expects($this->once())->method('loadLayout')->will($this->returnValue($this->getModelMock('core/layout')));
$this->_controller->expects($this->once())->method('renderLayout')->will($this->returnSelf());
EcomDev_Utils_Reflection::setRestrictedPropertyValues($this->_controller, ['_orderFactory' => $factory]);
$this->assertNull($this->_controller->romtrackingpopupAction());
}
示例14: testGetCurCustomerOrders
/**
* Test that the helper method ebayenterprise_order/data::getCurCustomerOrders()
* when invoked will call the helper method ebayenterprise_order/data::_getPrefixedCurrentCustomerId()
* which when return a non-empty string value the method ebayenterprise_order/factory::getNewRomOrderSearch()
* will be called and passed in the string literal customer id, in turn it will return an instance of type
* ebayenterprise_order/search. Then, the method ebayenterprise_order/search::process() will be invoked and return
* an instance of type ebayenterprise_order/search_process_response_collection. However, if the
* the helper method ebayenterprise_order/data::_getPrefixedCurrentCustomerId() return an empty string
* or a null value, then the method eb2ccore/data::getNewVarienDataCollection() will be invoked instead,
* which will return an instance of type Varien_Data_Collection. Finally, the helper method
* ebayenterprise_order/data::getCurCustomerOrders() will either return an empty Varien_Data_Collection object
* or a full ebayenterprise_order/search_process_response_collection object.
*
* @param string | null
* @dataProvider providerGetCurCustomerOrders
*/
public function testGetCurCustomerOrders($customerId)
{
$api = $this->getMockBuilder(static::API_CLASS)->disableOriginalConstructor()->getMock();
/** @var string */
$apiService = 'customers';
/** @var string */
$apiOperation = 'orders/get';
/** @var EbayEnterprise_Eb2cCore_Model_Config_Registry */
$orderCfg = $this->buildCoreConfigRegistry(['apiSearchService' => $apiService, 'apiSearchOperation' => $apiOperation]);
/** @var Varien_Data_Collection */
$result = is_null($customerId) ? new Varien_Data_Collection() : Mage::getModel('ebayenterprise_order/search_process_response_collection');
/** @var EbayEnterprise_Eb2cCore_Helper_Data */
$coreHelper = $this->getHelperMock('eb2ccore/data', ['getNewVarienDataCollection', 'getSdkApi']);
$coreHelper->expects(is_null($customerId) ? $this->once() : $this->never())->method('getNewVarienDataCollection')->will($this->returnValue($result));
$coreHelper->expects($this->any())->method('getSdkApi')->with($this->identicalTo($apiService), $this->identicalTo($apiOperation))->will($this->returnValue($api));
/** @var EbayEnterprise_Order_Model_Search */
$search = $this->getModelMock('ebayenterprise_order/search', ['process'], false, [['customer_id' => $customerId, 'core_helper' => $coreHelper, 'order_cfg' => $orderCfg]]);
$search->expects(is_null($customerId) ? $this->never() : $this->once())->method('process')->will($this->returnValue($result));
/** @var EbayEnterprise_Order_Helper_Factory */
$factory = $this->getHelperMock('ebayenterprise_order/factory', ['getNewRomOrderSearch']);
$factory->expects(is_null($customerId) ? $this->never() : $this->once())->method('getNewRomOrderSearch')->with($this->identicalTo($customerId))->will($this->returnValue($search));
/** @var EbayEnterprise_Order_Helper_Data */
$helper = $this->getHelperMock('ebayenterprise_order/data', ['_getPrefixedCurrentCustomerId']);
$helper->expects($this->once())->method('_getPrefixedCurrentCustomerId')->will($this->returnValue($customerId));
EcomDev_Utils_Reflection::setRestrictedPropertyValues($helper, ['_coreHelper' => $coreHelper, '_factory' => $factory]);
$this->assertSame($result, $helper->getCurCustomerOrders());
}
示例15: testGetPaymentMarkUrl
/**
* Scenario: Get the "What Is PayPal" localized URL
*
* When getWhatIsPayPalUrl is called
* Then a localized url is returned
* When a url is set in the config
* Then that url will be returned
*
* @dataProvider provideOverrideWhatIsPageUrl
*/
public function testGetPaymentMarkUrl($configValue, $expectedUrl)
{
$this->config = $this->buildCoreConfigRegistry(['markImageSrc' => null, 'paymentMarkSize' => null, 'whatIsPageUrl' => $configValue]);
EcomDev_Utils_Reflection::setRestrictedPropertyValues($this->block, ['config' => $this->config]);
$this->assertSame($expectedUrl, $this->block->getWhatIsPayPalUrl());
}