paymentDOMock = $this->createMock(PaymentDataObjectInterface::class); $this->paymentMock = $this->createMock(Payment::class); $this->orderMock = $this->createMock(Order::class); $this->paymentDOMock->method('getPayment') ->willReturn($this->paymentMock); $this->builder = new TransactionDetailsDataBuilder(new SubjectReader()); } public function testBuild() { $transactionMock = $this->createMock(Transaction::class); $this->paymentMock->method('getAuthorizationTransaction') ->willReturn($transactionMock); $transactionMock->method('getParentTxnId') ->willReturn('foo'); $expected = [ 'transId' => 'foo' ]; $buildSubject = [ 'payment' => $this->paymentDOMock, ]; $this->assertEquals($expected, $this->builder->build($buildSubject)); } public function testBuildWithIncludedTransactionId() { $transactionMock = $this->createMock(Transaction::class); $this->paymentMock->expects($this->never()) ->method('getAuthorizationTransaction'); $transactionMock->expects($this->never()) ->method('getParentTxnId'); $expected = [ 'transId' => 'foo' ]; $buildSubject = [ 'payment' => $this->paymentDOMock, 'transactionId' => 'foo' ]; $this->assertEquals($expected, $this->builder->build($buildSubject)); } }