13 use PHPUnit_Framework_MockObject_MockObject as MockObject;
23 private $paymentDOMock;
38 private $subjectReaderMock;
42 $this->paymentDOMock = $this->createMock(PaymentDataObjectInterface::class);
43 $this->orderMock = $this->createMock(OrderAdapterInterface::class);
44 $this->subjectReaderMock = $this->getMockBuilder(SubjectReader::class)
45 ->disableOriginalConstructor()
60 $this->subjectReaderMock->expects(self::once())
61 ->method(
'readPayment')
63 ->willThrowException(
new \InvalidArgumentException());
65 $this->builder->build($buildSubject);
70 $this->paymentDOMock->expects(static::once())
72 ->willReturn($this->orderMock);
74 $this->orderMock->expects(static::once())
75 ->method(
'getShippingAddress')
77 $this->orderMock->expects(static::once())
78 ->method(
'getBillingAddress')
82 'payment' => $this->paymentDOMock,
85 $this->subjectReaderMock->expects(self::once())
86 ->method(
'readPayment')
88 ->willReturn($this->paymentDOMock);
90 static::assertEquals([], $this->builder->build($buildSubject));
103 $this->paymentDOMock->expects(static::once())
105 ->willReturn($this->orderMock);
107 $this->orderMock->expects(static::once())
108 ->method(
'getShippingAddress')
109 ->willReturn($addressMock);
110 $this->orderMock->expects(static::once())
111 ->method(
'getBillingAddress')
112 ->willReturn($addressMock);
115 'payment' => $this->paymentDOMock,
118 $this->subjectReaderMock->expects(self::once())
119 ->method(
'readPayment')
120 ->with($buildSubject)
121 ->willReturn($this->paymentDOMock);
123 self::assertEquals($expectedResult, $this->builder->build($buildSubject));
134 'first_name' =>
'John',
135 'last_name' =>
'Smith',
136 'company' =>
'Magento',
137 'street_1' =>
'street1',
138 'street_2' =>
'street2',
140 'region_code' =>
'IL',
141 'country_id' =>
'US',
142 'post_code' =>
'00000',
179 $addressMock = $this->createMock(AddressAdapterInterface::class);
181 $addressMock->expects(self::exactly(2))
182 ->method(
'getFirstname')
184 $addressMock->expects(self::exactly(2))
185 ->method(
'getLastname')
187 $addressMock->expects(self::exactly(2))
188 ->method(
'getCompany')
190 $addressMock->expects(self::exactly(2))
191 ->method(
'getStreetLine1')
193 $addressMock->expects(self::exactly(2))
194 ->method(
'getStreetLine2')
196 $addressMock->expects(self::exactly(2))
199 $addressMock->expects(self::exactly(2))
200 ->method(
'getRegionCode')
202 $addressMock->expects(self::exactly(2))
203 ->method(
'getPostcode')
205 $addressMock->expects(self::exactly(2))
206 ->method(
'getCountryId')
testBuild($addressData, $expectedResult)
testBuildReadPaymentException()