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->paymentDOMock->method('getOrder') ->willReturn($this->orderMock); $this->builder = new ShippingDataBuilder( new SubjectReader() ); } public function testBuild() { $this->orderMock->method('getBaseShippingAmount') ->willReturn('43.12'); $expected = [ 'transactionRequest' => [ 'shipping' => [ 'amount' => '43.12' ] ] ]; $buildSubject = [ 'payment' => $this->paymentDOMock, 'order' => $this->orderMock, ]; $this->assertEquals($expected, $this->builder->build($buildSubject)); } }