14 use PHPUnit_Framework_MockObject_MockObject as MockObject;
24 private $subjectReaderMock;
29 private $paymentDOMock;
34 private $paymentModelMock;
44 private $transactionId =
'xsd7n';
48 $this->paymentModelMock = $this->getMockBuilder(Payment::class)
49 ->disableOriginalConstructor()
52 $this->subjectReaderMock = $this->getMockBuilder(SubjectReader::class)
53 ->disableOriginalConstructor()
61 $this->initPaymentDOMock();
62 $buildSubject = [
'payment' => $this->paymentDOMock,
'amount' => 12.358];
64 $this->subjectReaderMock->expects(self::once())
65 ->method(
'readPayment')
67 ->willReturn($this->paymentDOMock);
68 $this->paymentModelMock->expects(self::once())
69 ->method(
'getParentTransactionId')
70 ->willReturn($this->transactionId);
71 $this->subjectReaderMock->expects(self::once())
72 ->method(
'readAmount')
74 ->willReturn($buildSubject[
'amount']);
78 'transaction_id' => $this->transactionId,
81 $this->dataBuilder->build($buildSubject)
87 $this->initPaymentDOMock();
88 $buildSubject = [
'payment' => $this->paymentDOMock];
90 $this->subjectReaderMock->expects(self::once())
91 ->method(
'readPayment')
93 ->willReturn($this->paymentDOMock);
94 $this->paymentModelMock->expects(self::once())
95 ->method(
'getParentTransactionId')
96 ->willReturn($this->transactionId);
97 $this->subjectReaderMock->expects(self::once())
98 ->method(
'readAmount')
100 ->willThrowException(
new \InvalidArgumentException());
102 static::assertEquals(
104 'transaction_id' => $this->transactionId,
107 $this->dataBuilder->build($buildSubject)
113 $this->initPaymentDOMock();
114 $buildSubject = [
'payment' => $this->paymentDOMock];
117 $this->subjectReaderMock->expects(self::once())
118 ->method(
'readPayment')
119 ->with($buildSubject)
120 ->willReturn($this->paymentDOMock);
121 $this->paymentModelMock->expects(self::once())
122 ->method(
'getParentTransactionId')
123 ->willReturn($legacyTxnId);
124 $this->subjectReaderMock->expects(self::once())
125 ->method(
'readAmount')
126 ->with($buildSubject)
127 ->willThrowException(
new \InvalidArgumentException());
129 static::assertEquals(
131 'transaction_id' => $this->transactionId,
134 $this->dataBuilder->build($buildSubject)
143 private function initPaymentDOMock()
145 $this->paymentDOMock = $this->createMock(PaymentDataObjectInterface::class);
146 $this->paymentDOMock->expects(self::once())
147 ->method(
'getPayment')
148 ->willReturn($this->paymentModelMock);
testBuildCutOffLegacyTransactionIdPostfix()