8 use Braintree\Result\Successful;
14 use PHPUnit_Framework_MockObject_MockObject as MockObject;
15 use Psr\Log\LoggerInterface;
37 protected function setUp()
40 $criticalLoggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
41 $this->loggerMock = $this->getMockBuilder(Logger::class)
42 ->disableOriginalConstructor()
43 ->setMethods([
'debug'])
46 $this->adapterMock = $this->getMockBuilder(BraintreeAdapter::class)
47 ->disableOriginalConstructor()
48 ->setMethods([
'submitForSettlement'])
51 $adapterFactoryMock = $this->getMockBuilder(BraintreeAdapterFactory::class)
52 ->disableOriginalConstructor()
54 $adapterFactoryMock->method(
'create')
55 ->willReturn($this->adapterMock);
69 public function testPlaceRequestWithException()
71 $exception = new \Exception(
'Transaction has been declined');
72 $this->adapterMock->expects(static::once())
73 ->method(
'submitForSettlement')
74 ->willThrowException($exception);
77 $transferObject = $this->getTransferObjectMock();
78 $this->client->placeRequest($transferObject);
84 public function testPlaceRequest()
86 $data =
new Successful([
'success'], [
true]);
87 $this->adapterMock->expects(static::once())
88 ->method(
'submitForSettlement')
92 $transferObject = $this->getTransferObjectMock();
93 $response = $this->client->placeRequest($transferObject);
94 static::assertTrue(is_object(
$response[
'object']));
103 private function getTransferObjectMock()
105 $mock = $this->createMock(TransferInterface::class);
106 $mock->expects($this->once())
109 'transaction_id' =>
'vb4c6b',