/** * Test that the method ebayenterprise_order/abstract_send::send() * is invoked, and it will call the method ebayenterprise_order/abstract_send::_sendRequest(). * Finally, the method ebayenterprise_order/abstract_send::send() will return * an instance of type IOrderCancelResponse. */ public function testSendOrderCancelRequestPayload() { /** @var Mock_IOrderCancelRequest */ $request = $this->getMockBuilder(EbayEnterprise_Order_Model_Cancel_Build_IRequest::PAYLOAD_CLASS)->disableOriginalConstructor()->getMock(); /** @var Mock_IOrderCancelResponse */ $response = $this->getMockBuilder(static::RESPONSE_CLASS)->disableOriginalConstructor()->getMock(); $this->_api->expects($this->any())->method('getRequestBody')->will($this->returnValue($response)); /** @var Mock_EbayEnterprise_Order_Model_Abstract_Send */ $cancelSendRequest = $this->getModelMock('ebayenterprise_order/abstract_send', ['_sendRequest'], true, [['api' => $this->_api, 'request' => $request]]); $cancelSendRequest->expects($this->once())->method('_sendRequest')->will($this->returnValue($response)); $this->assertSame($response, $cancelSendRequest->send()); }
/** * 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', [])); }
/** * Test that the method ebayenterprise_order/cancel_build_request::_getReasonDescription() * is invoked, and it will call the varien magic method sales/order::getCancelReasonCode(). * If the varien magic method sales/order::getCancelReasonCode() return a non-empty * string value then the helper method ebayenterprise_order/data::getCancelReasonDescription() * will invoked and passed in the as parameter the return value from calling the * varien magic method sales/order::getCancelReasonCode(). The method * ebayenterprise_order/cancel_build_request::_getReasonDescription() will simply return that value. * However, if the return value from calling the varien magic method sales/order::getCancelReasonCode() * an empty string or null, then the method ebayenterprise_order/cancel_build_request::_getReasonDescription() * will return null. * @param Mage_Sales_Model_Order * @param string * @dataProvider providerGetReasonDescription */ public function testGetReasonDescription(Mage_Sales_Model_Order $order, $result) { $this->_api->expects($this->any())->method('getRequestBody')->will($this->returnValue($this->_payload)); $code = $order->getCancelReasonCode(); $orderHelper = $this->getHelperMock('ebayenterprise_order/data', ['getCancelReasonDescription']); $orderHelper->expects($code ? $this->once() : $this->never())->method('getCancelReasonDescription')->with($this->identicalTo($code))->will($this->returnValue($result)); /** @var EbayEnterprise_Order_Model_Cancel_Build_Request */ $buildRequest = Mage::getModel('ebayenterprise_order/cancel_build_request', ['api' => $this->_api, 'order' => $order, 'order_helper' => $orderHelper]); $this->assertSame($result, EcomDev_Utils_Reflection::invokeRestrictedMethod($buildRequest, '_getReasonDescription', [])); }
/** * Test that the method ebayenterprise_order/search_build_request::_buildOrderSearch() * is invoked, and it will be passed in an instance of type IOrderSearch. Then, the method * IOrderSearch::setCustomerId() will be called and passed in the customer id. Then, the method * IOrderSearch::setCustomerOrderId() will be invoked and passed in the order id. Finally, * the method ebayenterprise_order/search_build_request::_buildOrderSearch() will return * the instance of type IOrderSearch. */ public function testBuildOrderSearch() { /** @var string */ $customerId = '006512'; /** @var null */ $orderId = null; $this->_api->expects($this->any())->method('getRequestBody')->will($this->returnValue($this->_payload)); /** @var Mock_IOrderSearch */ $orderSearch = $this->getMockBuilder(static::SUB_PAYLOAD_CLASS)->disableOriginalConstructor()->setMethods(['setCustomerId', 'setCustomerOrderId'])->getMock(); $orderSearch->expects($this->once())->method('setCustomerId')->with($this->identicalTo($customerId))->will($this->returnSelf()); $orderSearch->expects($this->once())->method('setCustomerOrderId')->with($this->identicalTo($orderId))->will($this->returnSelf()); /** @var Mock_EbayEnterprise_Order_Model_Search_Build_Request */ $buildRequest = Mage::getModel('ebayenterprise_order/search_build_request', ['customer_id' => $customerId, 'api' => $this->_api]); $this->assertSame($orderSearch, EcomDev_Utils_Reflection::invokeRestrictedMethod($buildRequest, '_buildOrderSearch', [$orderSearch])); }