Beispiel #1
1
 /**
  * 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;
 }
 public function setUp()
 {
     $this->_helper = $this->getHelperMock('ebayenterprise_giftcard/data');
     $this->_helper->expects($this->any())->method('__')->with($this->isType('string'))->will($this->returnArgument(0));
     // disable constructor to prevent having to mock dependencies
     $this->_checkoutSession = $this->getModelMockBuilder('checkout/session')->disableOriginalConstructor()->setMethods(array('addError'))->getMock();
     // disable constructor to prevent having to mock dependencies
     $this->_giftCardSession = $this->getModelMockBuilder('ebayenterprise_giftcard/session')->disableOriginalConstructor()->setMethods(array('setEbayEnterpriseCurrentGiftCard'))->getMock();
     // disable constructor to avoid mocking dependencies
     $this->_request = $this->getMockBuilder('Mage_Core_Controller_Request_Http')->disableOriginalConstructor()->getMock();
     $this->_request->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array(self::CARDNUMBER_FIELD, '', $this->_giftCardNumber), array(self::PIN_FIELD, '', $this->_giftCardPin))));
     $this->_giftCard = $this->getMock('EbayEnterprise_GiftCard_Model_IGiftcard');
     $this->_giftCard->expects($this->any())->method('setPin')->with($this->isType('string'))->will($this->returnSelf());
     // disable constructor to avoid mocking dependencies
     $this->_container = $this->getMockBuilder('EbayEnterprise_GiftCard_Model_IContainer')->disableOriginalConstructor()->getMock();
     // use value map so that if anything other than the giftcard number and pin are passed in,
     // the function will return null. so tests should fail if a change breaks assumptions about
     // getGiftCard's arguments.
     $this->_container->expects($this->any())->method('getGiftCard')->will($this->returnValueMap(array(array($this->_giftCardNumber, $this->_giftCard))));
     // disable constructor to avoid mocking dependencies
     $this->_controller = $this->getMockBuilder('EbayEnterprise_GiftCard_Controller_Abstract')->disableOriginalConstructor()->setMethods(array('_redirect', 'loadLayout', 'renderLayout', 'setFlag'))->getMock();
     // inject mocked dependencies
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->_controller, '_container', $this->_container);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->_controller, '_helper', $this->_helper);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->_controller, '_request', $this->_request);
 }
 /**
  * GIVEN An <sdkApi> that will thrown an <exception> of <exceptionType> when making a request.
  * WHEN A request is made.
  * THEN The <exception> will be caught.
  * AND An exception of <expectedExceptionType> will be thrown.
  *
  * @param string
  * @param string
  * @dataProvider provideSdkExceptions
  */
 public function testSdkExceptionHandling($exceptionType, $expectedExceptionType)
 {
     $exception = new $exceptionType(__METHOD__ . ': Test Exception');
     $this->api->method('send')->will($this->throwException($exception));
     $this->setExpectedException($expectedExceptionType);
     EcomDev_Utils_Reflection::invokeRestrictedMethod($this->allocator, 'makeRequest', [$this->api]);
 }
 /**
  * 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());
 }
 /**
  *
  *
  * @param string $type
  * @param array $requiredKeys
  * @dataProvider dataProvider
  * @loadFixture config
  */
 public function testGetDefaultData($type, $requiredKeys)
 {
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->processor, 'requiredKeys', $requiredKeys);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->processor, 'type', $type);
     $dataSet = $this->readAttribute($this, 'dataName');
     $this->assertEquals($this->expected($dataSet)->getData(), $this->processor->getDefaultData());
 }
 /**
  * will log a warning when the result code is
  * for an error or is unknown
  * @dataProvider provideFailureResultCodes
  */
 public function testLogResultCodeWithError($code)
 {
     $response = $this->getModelMockBuilder('ebayenterprise_address/validation_response')->setConstructorArgs([['api' => $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Api\\IBidirectionalApi'), 'logger' => $this->logger, 'context' => $this->context]])->setMethods(['extractResponseData'])->getMock();
     $response->setResultCode($code);
     $this->logger->expects($this->once())->method('warning');
     EcomDev_Utils_Reflection::invokeRestrictedMethod($response, 'logResultCode');
 }
 /**
  * Test version
  *
  * @param string[]|string $directories
  * @param string $type
  * @param string $from
  * @param string $to
  *
  * @return void
  * @dataProvider dataProvider
  */
 public function testGetVersionScriptsDiff($directories, $type, $from, $to)
 {
     $virtualPath = $this->getVirtualPath($directories);
     $versions = EcomDev_Utils_Reflection::invokeRestrictedMethod($this->constraint, 'parseVersions', array($virtualPath));
     $result = EcomDev_Utils_Reflection::invokeRestrictedMethod($this->constraint, 'getVersionScriptsDiff', array($versions[$type], $from, $to, $type === 'data' ? 'data-' : ''));
     $this->assertEquals($this->expected('auto')->getDiff(), $result);
 }
 protected function tearDown()
 {
     // Restore the original inventory helper instance to the payload helper
     // to prevent the mock form potentially polluting other tests with
     // unexpected mock behavior.
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->payloadHelper, 'inventoryHelper', $this->origInventoryHelper);
 }
Beispiel #9
0
 /**
  * Constructor adds test groups defined on global level
  * and adds additional logic for test names retrieval
  *
  * @see PHPUnit_Framework_TestSuite::__construct()
  */
 public function __construct($theClass = '', $groups = array())
 {
     if (!$theClass instanceof ReflectionClass) {
         $theClass = EcomDev_Utils_Reflection::getReflection($theClass);
     }
     // Check annotations for test case name
     $annotations = PHPUnit_Util_Test::parseTestMethodAnnotations($theClass->getName());
     if (isset($annotations['name'])) {
         $this->suiteName = $annotations['name'];
     }
     // Creates all test instances
     parent::__construct($theClass);
     // Just sort-out them by our internal groups
     foreach ($groups as $group) {
         $this->groups[$group] = $this->tests();
     }
     foreach ($this->tests() as $test) {
         if ($test instanceof PHPUnit_Framework_TestSuite) {
             /* @todo
              * Post an issue into PHPUnit bugtracker for
              * impossibility for specifying group by parent test case
              * Because it is a very dirty hack :(
              **/
             $testGroups = array();
             foreach ($groups as $group) {
                 $testGroups[$group] = $test->tests();
             }
             EcomDev_Utils_Reflection::setRestrictedPropertyValue($test, 'groups', $testGroups);
         }
     }
     // Remove un grouped tests group, if it exists
     if (isset($this->groups[self::NO_GROUP_KEYWORD])) {
         unset($this->groups[self::NO_GROUP_KEYWORD]);
     }
 }
 public function testReturnsCorrectImageProcessorClass()
 {
     /** @var $image Varien_Image */
     $image = $this->_model->getImageProcessor();
     $adapterClass = EcomDev_Utils_Reflection::invokeRestrictedMethod($image, '_getAdapter');
     $this->assertInstanceOf('Varien_Image_Adapter_Abstract', $adapterClass);
 }
 /**
  * verify
  * - the localized and default values are returned
  * - if the option does not exist, null is returned
  *   for both default and localized values
  *
  * @param  string $method
  * @param  string $localizedValue
  * @param  string $defaultValue
  * @dataProvider provideForSizeColorInfo
  */
 public function testGetItemColorAndSizeInfo($method, $localizedValue, $defaultValue)
 {
     $this->replaceByMock('resource_model', 'eav/entity_attribute_option_collection', $this->optionValueCollectionStub);
     $this->optionValueCollectionStub->addItem(Mage::getModel('eav/entity_attribute_option', ['attribute_code' => 'color', 'option_id' => 15, 'value' => 'Black', 'default_value' => '2']));
     $handler = Mage::getModel('ebayenterprise_order/create_orderitem');
     $this->assertSame([$localizedValue, $defaultValue], EcomDev_Utils_Reflection::invokeRestrictedMethod($handler, $method, [$this->itemStub]));
 }
 /**
  * Test getting the fields to include in the feed. Should be pulling the
  * comma-separated list of fields from config.xml and splitting it to produce
  * an array of fields.
  * @return array
  */
 public function testFeedFields()
 {
     $config = $this->getHelperMock('eems_affiliate/config', array('getItemizedOrderFeedFields'));
     $config->expects($this->any())->method('getItemizedOrderFeedFields')->will($this->returnValue('one,two,three'));
     $this->replaceByMock('helper', 'eems_affiliate/config', $config);
     $feed = Mage::getModel('eems_affiliate/feed_order_itemized');
     $this->assertSame(array('one', 'two', 'three'), EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFeedFields'));
 }
Beispiel #13
0
 public function testRemoveMethod()
 {
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->mockProxy, 'methods', array('methodName', 'methodName2', 'methodName3'));
     $this->mockProxy->removeMethod('methodName2');
     $this->assertAttributeEquals(array('methodName', 'methodName3'), 'methods', $this->mockProxy);
     $this->mockProxy->removeMethod('methodName');
     $this->assertAttributeEquals(array('methodName3'), 'methods', $this->mockProxy);
 }
Beispiel #14
0
 /**
  * Proxied mock instance retrieval
  *
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 public function getMockInstance()
 {
     if ($this->mockInstance === null) {
         $reflection = ReflectionUtil::getReflection(ReflectionUtil::getRestrictedPropertyValue($this, 'type'));
         $this->mockInstance = $reflection->isAbstract() || $reflection->isInterface() ? $this->getMockForAbstractClass() : $this->getMock();
     }
     return $this->mockInstance;
 }
 /**
  * Test _getGiftCardType method for the following expectations
  * Expectation 1: when this test invoked the method EbayEnterprise_Catalog_Helper_Map_Giftcard::_getGiftCardType
  *                with string of each giftcard constant type it will return the gift card constant value
  */
 public function testGetGiftCardType()
 {
     $testData = array(array('expect' => Enterprise_GiftCard_Model_Giftcard::TYPE_VIRTUAL, 'type' => EbayEnterprise_Catalog_Helper_Map_Giftcard::GIFTCARD_VIRTUAL), array('expect' => Enterprise_GiftCard_Model_Giftcard::TYPE_PHYSICAL, 'type' => EbayEnterprise_Catalog_Helper_Map_Giftcard::GIFTCARD_PHYSICAL), array('expect' => Enterprise_GiftCard_Model_Giftcard::TYPE_COMBINED, 'type' => EbayEnterprise_Catalog_Helper_Map_Giftcard::GIFTCARD_COMBINED));
     $giftcard = Mage::helper('ebayenterprise_catalog/map_giftcard');
     foreach ($testData as $data) {
         $this->assertSame($data['expect'], EcomDev_Utils_Reflection::invokeRestrictedMethod($giftcard, '_getGiftCardType', array($data['type'])));
     }
 }
 /**
  * Before an item is saved, if the item has an associated order address
  * with a valid id, the id of the order address should be set on the item.
  */
 public function testBeforeSave()
 {
     $addressId = 8;
     $address = Mage::getModel('sales/order_address', ['entity_id' => $addressId]);
     $this->_item->setOrderAddress($address);
     EcomDev_Utils_Reflection::invokeRestrictedMethod($this->_item, '_beforeSave');
     $this->assertSame($addressId, $this->_item->getOrderAddressId());
 }
 public function testGetTenderTypeLookupApi()
 {
     $service = 'payments';
     $operation = 'tendertype/lookup';
     $tenderTypeHelper = $this->getHelperMockBuilder('ebayenterprise_giftcard/tendertype')->setMethods(null)->setConstructorArgs([$this->constructorArgs])->getMock();
     $this->api = $this->getMockBuilder('\\eBayEnterprise\\RetailOrderManagement\\Api\\IBidirectionalApi')->getMockForAbstractClass();
     $this->coreHelper->expects($this->once())->method('getSdkApi')->with($this->identicalTo($service), $this->identicalTo($operation), $this->identicalTo([]), $this->identicalTo($this->apiLogger))->will($this->returnValue($this->api));
     $this->assertSame($this->api, EcomDev_Utils_Reflection::invokeRestrictedMethod($tenderTypeHelper, 'getTenderTypeLookupApi'));
 }
 public function testConfigurationSavedIfModuleNotInstalled()
 {
     $imagemagickMock = $this->getMock('Varien_Image_Adapter_Imagemagic', array('checkDependencies'));
     $imagemagickMock->expects($this->any())->method('checkDependencies')->will($this->returnValue(true));
     $this->_model->setImageAdapter($imagemagickMock);
     $this->_model->setValue(Varien_Image_Adapter::ADAPTER_GD2);
     EcomDev_Utils_Reflection::invokeRestrictedMethod($this->_model, '_beforeSave');
     $this->assertEquals(Varien_Image_Adapter::ADAPTER_GD2, $this->_model->getValue());
 }
 /**
  * Test that the method ebayenterprise_order/search_process_response_collection::_sortOrdersMostRecentFirst()
  * is invoked, and it will be passed in an object of type Varien_Object as parameter 1 and 2. When the
  * Varien_Object instance of parameter one has an order date greater and the Varien_Object instance of
  * parameter two, then the method ebayenterprise_order/search_process_response_collection::_sortOrdersMostRecentFirst()
  * will return boolean false, otherwise it will return true.
  *
  * @param string
  * @param string
  * @param bool
  * @dataProvider providerSortOrdersMostRecentFirst
  */
 public function testSortOrdersMostRecentFirst($orderDateA, $orderDateB, $result)
 {
     /** @var EbayEnterprise_Order_Model_Search_Process_Response_ICollection */
     $collection = Mage::getModel('ebayenterprise_order/search_process_response_collection');
     /** @var Varien_Object */
     $varienObjectA = new Varien_Object(['order_date' => $orderDateA]);
     /** @var Varien_Object */
     $varienObjectB = new Varien_Object(['order_date' => $orderDateB]);
     $this->assertSame($result, EcomDev_Utils_Reflection::invokeRestrictedMethod($collection, '_sortOrdersMostRecentFirst', [$varienObjectA, $varienObjectB]));
 }
 /**
  * Test EbayEnterprise_Catalog_Helper_Map_Stock::_getStockMap method with the following expectations
  * Expectation 1: when this test invoked this method EbayEnterprise_Catalog_Helper_Map_Stock::_getStockMap
  *                will set the class property EbayEnterprise_Catalog_Helper_Map_Stock::_StockMap with an
  *                array of ROM SalesClass values mapped to valid (we hope) Magento_CatalogInventory_Model_Stock::BACKORDER_xxx value
  */
 public function testGetStockMap()
 {
     $mapData = array('advanceOrderOpen' => 1, 'advanceOrderLimited' => 2);
     $configRegistryMock = $this->getModelMock('eb2ccore/config_registry', array('getConfigData'));
     $configRegistryMock->expects($this->once())->method('getConfigData')->with($this->identicalTo(EbayEnterprise_Catalog_Helper_Map_Stock::STOCK_CONFIG_PATH))->will($this->returnValue($mapData));
     $this->replaceByMock('model', 'eb2ccore/config_registry', $configRegistryMock);
     $stock = Mage::helper('ebayenterprise_catalog/map_stock');
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($stock, '_stockMap', array());
     $this->assertSame($mapData, EcomDev_Utils_Reflection::invokeRestrictedMethod($stock, '_getStockMap', array()));
 }
Beispiel #21
0
 public function tearDown()
 {
     $collection = $this->getProductSyncCronScheduleCollection();
     foreach ($collection as $item) {
         $item->delete();
     }
     $resource = Mage::getModel("core/resource");
     $resource->getConnection("core_write")->delete($resource->getTableName("klevu_search/order_sync"));
     EcomDev_Utils_Reflection::setRestrictedPropertyValue(Mage::getConfig(), "_classNameCache", array());
     parent::tearDown();
 }
Beispiel #22
0
 /**
  * Resets translator data
  *
  * @return EcomDev_PHPUnit_Model_App_Area
  */
 public function resetTranslate()
 {
     $translator = $this->_application->getTranslator();
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_config', null);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_locale', null);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_cacheId', null);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_translateInline', null);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_dataScope', null);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_data', array());
     return $this;
 }
 /**
  * When a language code is found to be invalid, an exception should be thrown.
  */
 public function testInvalidLanguageCodeException()
 {
     $mockLangHelper = $this->getHelperMock('eb2ccore/languages', ['validateLanguageCode']);
     $mockLangHelper->expects($this->any())->method('validateLanguageCode')->will($this->returnValue(false));
     $mockCoreHelper = $this->getHelperMock('eb2ccore/data', ['__']);
     $mockCoreHelper->expects($this->any())->method('__')->will($this->returnArgument(0));
     $backendMock = $this->getModelMockBuilder('eb2ccore/system_config_backend_language_code')->setMethods(array('isValueChanged'))->setConstructorArgs([['language_helper' => $mockLangHelper, 'core_helper' => $mockCoreHelper]])->getMock();
     $backendMock->expects($this->once())->method('isValueChanged')->will($this->returnValue(true));
     $this->setExpectedException('EbayEnterprise_Eb2cCore_Exception');
     EcomDev_Utils_Reflection::invokeRestrictedMethod($backendMock->setValue("invalidlangcode"), '_beforeSave');
 }
 /**
  * Test getting the last saved test message timestamp to be displayed in the
  * admin.
  * @param string|null $timestamp
  * @param string $value
  * @dataProvider provideLastTimestamp
  */
 public function testAfterLoad($lastTimestamp, $value)
 {
     // suppression the real session from starting
     $session = $this->getModelMockBuilder('core/session')->disableOriginalConstructor()->setMethods(null)->getMock();
     $this->replaceByMock('singleton', 'core/session', $session);
     $helper = $this->getHelperMock('ebayenterprise_amqp/data');
     $helper->expects($this->any())->method('__')->will($this->returnArgument(0));
     $lasttestmessage = Mage::getModel('ebayenterprise_amqp/adminhtml_system_config_backend_lasttestmessage', array('value' => $lastTimestamp, 'helper' => $helper));
     EcomDev_Utils_Reflection::invokeRestrictedMethod($lasttestmessage, '_afterLoad');
     $this->assertSame($value, $lasttestmessage->getValue());
 }
 /**
  * verify an exception is thrown when missing arguments
  */
 public function testConstructInvalidArguments()
 {
     $expectedException = sprintf(EbayEnterprise_Catalog_Model_Pim_Product::ERROR_INVALID_ARGS, 'EbayEnterprise_Catalog_Model_Pim_Product::_construct', 'client_id, catalog_id, sku');
     $initParams = array();
     $this->setExpectedException('Exception', $expectedException);
     $helper = $this->getHelperMockBuilder('eb2ccore/data')->disableOriginalConstructor()->setMethods(array('triggerError'))->getMock();
     $helper->expects($this->once())->method('triggerError')->with($this->identicalTo($expectedException))->will($this->throwException(new Exception($expectedException)));
     $this->replaceByMock('helper', 'eb2ccore', $helper);
     $product = $this->getModelMockBuilder('ebayenterprise_catalog/pim_product')->disableOriginalConstructor()->setMethods(null)->getMock();
     EcomDev_Utils_Reflection::invokeRestrictedMethod($product, '_construct', array($initParams));
 }
 /**
  * @singleton core/layout
  */
 public function testItReplacesRegularLayoutWithCompilerOne()
 {
     $originalValue = Mage::app()->getLayout();
     $manager = $this->mockModel('ecomdev_layoutcompiler/manager')->replaceByMock('singleton');
     $manager->expects($this->once())->method('isEnabled')->willReturn(true);
     $layout = $this->getMockForAbstractClass('EcomDev_LayoutCompiler_Contract_LayoutInterface');
     $manager->expects($this->once())->method('getLayout')->willReturn($layout);
     $this->observer->replaceLayout();
     $this->assertSame($layout, Mage::registry('_singleton/core/layout'));
     $this->assertSame($layout, Mage::app()->getLayout());
     EcomDev_Utils_Reflection::setRestrictedPropertyValue(Mage::app(), '_layout', $originalValue);
 }
 /**
  * Scenario: Get CSR Administrative user startup page URL
  * When getting CSR Administrative user startup page URL
  * Then get the user's configured startup URL path
  * And get the full URL using the startup URL path
  */
 public function testGetStartpageUri()
 {
     $adminUrl = 'admin/some/where';
     $expectedUrl = "https://example-test.com/index.php/{$adminUrl}";
     $url = $this->getModelMockBuilder('adminhtml/url')->disableOriginalConstructor()->setMethods(['getUrl'])->getMock();
     $url->expects($this->once())->method('getUrl')->with($this->identicalTo($adminUrl))->will($this->returnValue($expectedUrl));
     $user = $this->getModelMockBuilder('admin/user')->disableOriginalConstructor()->setMethods(['getStartupPageUrl'])->getMock();
     $user->expects($this->once())->method('getStartupPageUrl')->will($this->returnValue($adminUrl));
     $session = $this->getModelMockBuilder('admin/session')->disableOriginalConstructor()->setMethods(['getUser'])->getMock();
     $session->expects($this->once())->method('getUser')->will($this->returnValue($user));
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($session, 'url', $url);
     $this->assertSame($expectedUrl, EcomDev_Utils_Reflection::invokeRestrictedMethod($session, '_getStartpageUri'));
 }
 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);
 }
 /**
  * Test that the method ebayenterprise_order/detail_build_request::_buildPayload()
  * is invoked, and it will call the method IOrderDetailRequest::setOrderType() and passed in
  * the class constant EbayEnterprise_Order_Model_Detail_Build_IRequest::DEFAULT_ORDER_DETAIL_SEARCH_TYPE.
  * Then, the method IOrderDetailRequest::setCustomerOrderId() will be invoked and passed in
  * the order id. Finally, the method ebayenterprise_order/detail_build_request::_buildPayload() will
  * return itself.
  */
 public function testBuildPayloadForOrderDetailRequest()
 {
     /** @var string */
     $orderId = '1000049499939393881';
     /** @var Mock_IOrderDetailRequest */
     $payload = $this->getMockBuilder(static::PAYLOAD_CLASS)->disableOriginalConstructor()->setMethods(['setOrderType', 'setCustomerOrderId'])->getMock();
     $payload->expects($this->once())->method('setOrderType')->with($this->identicalTo(EbayEnterprise_Order_Model_Detail_Build_IRequest::DEFAULT_ORDER_DETAIL_SEARCH_TYPE))->will($this->returnSelf());
     $payload->expects($this->once())->method('setCustomerOrderId')->with($this->identicalTo($orderId))->will($this->returnSelf());
     $this->_api->expects($this->any())->method('getRequestBody')->will($this->returnValue($payload));
     /** @var Mock_EbayEnterprise_Order_Model_Detail_Build_Request */
     $buildRequest = $this->getModelMock('ebayenterprise_order/detail_build_request', ['foo'], false, [['order_id' => $orderId, 'api' => $this->_api]]);
     $this->assertSame($buildRequest, EcomDev_Utils_Reflection::invokeRestrictedMethod($buildRequest, '_buildPayload', []));
 }
 /**
  * verify:
  * - given an array with a 'token' key; the token will be stored as additionalinformation in the payment info model.
  * - the method will work with a varien object as well.
  *
  * @dataProvider provideTrueFalse
  */
 public function testAssignData($isDataObject)
 {
     $data = array('token' => 'thetokenstring', 'ignored_field' => 'ignored_value', 'shipping_address' => ['status' => 'right one'], 'billing_address' => ['status' => 'wrong one']);
     if ($isDataObject) {
         $data = new Varien_Object($data);
     }
     $express = Mage::getModel('ebayenterprise_paypal/method_express');
     $info = Mage::getModel('payment/info');
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($express, '_selectorKeys', array('token'));
     $express->setData('info_instance', $info);
     $express->assignData($data);
     $this->assertSame('thetokenstring', $info->getAdditionalInformation('token'));
     $this->assertSame('right one', $info->getAdditionalInformation(EbayEnterprise_PayPal_Model_Express_Checkout::PAYMENT_INFO_ADDRESS_STATUS));
 }