/** * prepare stubs */ public function setUp() { parent::setUp(); $this->_httpApi = $this->getMockBuilder('\\eBayEnterprise\\RetailOrderManagement\\Api\\HttpApi')->disableOriginalConstructor()->getMock(); $this->_observerStub = $this->getModelMock('ebayenterprise_order/observer'); $this->_itemSelection = $this->getHelperMock('ebayenterprise_order/item_selection', ['selectFrom']); $this->_payloadFactory = new PayloadFactory(); $this->_request = $this->_payloadFactory->buildPayload('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\OrderCreateRequest'); $this->_requestStub = $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\IOrderCreateRequest'); $this->_replyStub = $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\IOrderCreateReply'); $this->_coreHelperStub = $this->getHelperMock('eb2ccore/data', ['generateRequestId', 'getConfigModel']); $coreConfig = $this->buildCoreConfigRegistry(['clientCustomerIdPrefix' => $this->_clientCustomerIdPrefix, 'language_code' => 'en-us', 'clientCustomerIdLength' => 0]); $this->_coreHelperStub->expects($this->any())->method('getConfigModel')->will($this->returnValue($coreConfig)); $this->_config = $this->buildCoreConfigRegistry(['levelOfService' => $this->_expectedLevelOfService, 'orderType' => $this->_expectedOrderType, 'requestIdPrefix' => $this->_expectedRequestIdPrefix, 'apiCreateOperation' => 'create', 'apiService' => 'orders', 'genderMap' => ['Female' => 'F', 'Male' => 'M', 'SomeOtherGender' => 'Invalid']]); $this->_orderHelperStub = $this->getHelperMock('ebayenterprise_order', ['prefixCustomerId']); // Mock the customer id prefixing method to return the customer id // prefixed with the constant client customer id prefix. $clientCustomerIdPrefix = $this->_clientCustomerIdPrefix; $this->_orderHelperStub->method('prefixCustomerId')->will($this->returnCallback(function ($id) use($clientCustomerIdPrefix) { return $clientCustomerIdPrefix . $id; })); $this->_customer = Mage::getModel('customer/customer', ['increment_id' => '12345123456789']); $this->_order = Mage::getModel('sales/order', ['created_at' => '2014-07-28 16:22:46', 'customer' => $this->_customer, 'customer_dob' => '2014-07-28 16:22:46', 'customer_email' => '*****@*****.**', 'customer_firstname' => 'fname', 'customer_lastname' => 'lname', 'customer_middlename' => 'mname', 'customer_prefix' => 'mr', 'customer_id' => '123456789', 'customer_taxvat' => 'taxid', 'increment_id' => '12345123456789']); $this->_item1 = $this->getModelMock('sales/order_item', []); $this->_item2 = $this->getModelMock('sales/order_item', []); $this->_billAddress = Mage::getModel('sales/order_address', ['address_type' => Mage_Customer_Model_Address_Abstract::TYPE_BILLING, 'entity_id' => $this->_billAddressId]); $this->_shipAddress = Mage::getModel('sales/order_address', ['address_type' => Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING, 'entity_id' => $this->_shipAddressId]); // Mock log context to prevent session interactions while building out log data. $this->_logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']); $this->_logContext->method('getMetaData')->will($this->returnValue([])); // prevent magento events from actually triggering Mage::app()->disableEvents(); }
/** * Test that a properly configured SDK API is created for making * the tax request. */ public function testGetSdkApi() { // Allow the core helper to provide the correct API object // if given the appropriate configuration values for the // API service and operation. $this->_coreHelper->expects($this->any())->method('getSdkApi')->with($this->identicalTo($this->_apiService), $this->identicalTo($this->_apiOperation))->will($this->returnValue($this->_api)); $this->assertSame($this->_api, EcomDev_Utils_Reflection::invokeRestrictedMethod($this->_sdkHelper, '_getSdkApi')); }
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')); }
/** * Create the DOMDocument representing the feed. Should initialize (add root * node and message header) the DOMDocument, build out and append fragments * for each item to be included, and validate the resulting DOM. */ public function testCreateDomFromFeedData() { $itemNode = 'Item'; $isValidate = 'true'; $this->_doc->loadXML('<root></root>'); $itemFragment = $this->_doc->createDocumentFragment(); $itemFragment->appendChild($this->_doc->createElement('Item')); $pimProduct = $this->getModelMockBuilder('ebayenterprise_catalog/pim_product')->disableOriginalConstructor()->getMock(); $this->replaceByMock('helper', 'eb2ccore', $this->_coreHelper); $this->_coreHelper->expects($this->once())->method('parseBool')->with($this->identicalTo($isValidate))->will($this->returnValue(true)); $this->_pimProductCollection->expects($this->once())->method('getItems')->will($this->returnValue(array($pimProduct))); $pim = $this->getModelMockBuilder('ebayenterprise_catalog/pim')->disableOriginalConstructor()->setMethods(array('_buildItemNode', '_startDocument', '_validateDocument', '_getFeedConfig'))->getMock(); $pim->expects($this->once())->method('_startDocument')->will($this->returnSelf()); $pim->expects($this->once())->method('_buildItemNode')->with($this->identicalTo($pimProduct), $this->identicalTo($itemNode))->will($this->returnValue($itemFragment)); $pim->expects($this->once())->method('_validateDocument')->will($this->returnSelf()); $pim->expects($this->once())->method('_getFeedConfig')->will($this->returnValue($this->_feedTypeConfig)); EcomDev_Utils_Reflection::setRestrictedPropertyValue($pim, '_doc', $this->_doc); $this->assertSame($this->_doc, EcomDev_Utils_Reflection::invokeRestrictedMethod($pim, '_createDomFromFeedData', array($this->_pimProductCollection, $this->_feedTypeConfig))); $this->assertSame('<root><Item></Item></root>', $this->_doc->C14N()); }