_objectManager = Bootstrap::getObjectManager(); $httpClientFactoryMock = $this->getMockBuilder(LaminasClientFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->_httpClientMock = $this->getMockBuilder(LaminasClient::class)->setMethods([]) ->disableOriginalConstructor()->getMock(); $this->_httpClientMock->expects($this->any())->method('setUri')->willReturnSelf(); $this->_httpClientMock->expects($this->any())->method('setOptions')->willReturnSelf(); $this->_httpClientMock->expects($this->any())->method('setMethod')->willReturnSelf(); $this->_httpClientMock->expects($this->any())->method('setParameterPost')->willReturnSelf(); $this->_httpClientMock->expects($this->any())->method('setHeaders')->willReturnSelf(); $this->_httpClientMock->expects($this->any())->method('setUrlEncodeBody')->willReturnSelf(); $httpClientFactoryMock->expects($this->any())->method('create') ->willReturn($this->_httpClientMock); $mathRandomMock = $this->createMock(Random::class); $loggerMock = $this->createMock(Logger::class); $this->gatewayMock =$this->_objectManager->create( Gateway::class, [ 'httpClientFactory' => $httpClientFactoryMock, 'mathRandom' => $mathRandomMock, 'logger' => $loggerMock, ] ); $this->_model = $this->_objectManager->create( Payflowpro::class, ['gateway' => $this->gatewayMock] ); } /** * @magentoDataFixture Magento/Sales/_files/order_paid_with_payflowpro.php */ public function testReviewPaymentNullResponce() { /** @var Order $order */ $order = $this->_objectManager->create(Order::class); $order->loadByIncrementId('100000001'); $this->_httpClientMock->expects($this->any())->method('send') ->willReturn(new DataObject(['body' => 'RESULTval=12&val2=34'])); $expectedResult = ['resultval' => '12', 'val2' => '34', 'result_code' => null]; $this->assertEquals($expectedResult, $this->_model->acceptPayment($order->getPayment())); } }