paymentDOMock = $this->createMock(PaymentDataObjectInterface::class); $this->paymentMock = $this->createMock(Payment::class); $this->paymentDOMock->method('getPayment') ->willReturn($this->paymentMock); $this->orderMock = $this->createMock(OrderAdapterInterface::class); $this->paymentDOMock->method('getOrder') ->willReturn($this->orderMock); $this->builder = new CustomerDataBuilder(new SubjectReader()); } public function testBuild() { $addressAdapterMock = $this->createMock(AddressAdapterInterface::class); $addressAdapterMock->method('getEmail') ->willReturn('foo@bar.com'); $this->orderMock->method('getBillingAddress') ->willReturn($addressAdapterMock); $this->orderMock->method('getCustomerId') ->willReturn('123'); $expected = [ 'transactionRequest' => [ 'customer' => [ 'id' => '123', 'email' => 'foo@bar.com' ] ] ]; $buildSubject = [ 'payment' => $this->paymentDOMock, ]; $this->assertEquals($expected, $this->builder->build($buildSubject)); } }