示例#1
0
 public function testExecute()
 {
     $commandSubject = ['authorize'];
     $request = ['request_field1' => 'request_value1', 'request_field2' => 'request_value2'];
     $response = ['response_field1' => 'response_value1'];
     $transferO = $this->getMockBuilder('Magento\\Payment\\Gateway\\Http\\TransferInterface')->getMockForAbstractClass();
     $this->requestBuilderMock->expects($this->once())->method('build')->with($commandSubject)->willReturn($request);
     $this->transferBuilderMock->expects($this->once())->method('build')->with($request)->willReturn($transferO);
     $this->gatewayMock->expects($this->once())->method('placeRequest')->with($transferO)->willReturn($response);
     $this->responseHandlerMock->expects($this->once())->method('handle')->with($commandSubject, $response);
     $this->model->execute($commandSubject);
 }
 public function testExecute()
 {
     $commandSubject = ['authorize'];
     $request = ['request_field1' => 'request_value1', 'request_field2' => 'request_value2'];
     $response = ['response_field1' => 'response_value1'];
     $validationResult = $this->getMockBuilder('Magento\\Payment\\Gateway\\Validator\\ResultInterface')->getMockForAbstractClass();
     $transferO = $this->getMockBuilder('Magento\\Payment\\Gateway\\Http\\TransferInterface')->getMockForAbstractClass();
     $this->requestBuilderMock->expects(static::once())->method('build')->with($commandSubject)->willReturn($request);
     $this->transferFactoryMock->expects(static::once())->method('create')->with($request)->willReturn($transferO);
     $this->clientMock->expects(static::once())->method('placeRequest')->with($transferO)->willReturn($response);
     $this->validatorMock->expects(static::once())->method('validate')->with(array_merge($commandSubject, ['response' => $response]))->willReturn($validationResult);
     $validationResult->expects(static::once())->method('isValid')->willReturn(true);
     $this->responseHandlerMock->expects(static::once())->method('handle')->with($commandSubject, $response);
     $this->command->execute($commandSubject);
 }