paymentDOMock = $this->createMock(PaymentDataObjectInterface::class); $this->paymentMock = $this->createMock(Payment::class); $this->paymentDOMock->method('getPayment') ->willReturn($this->paymentMock); $this->builder = new PoDataBuilder(new SubjectReader()); } public function testBuild() { $this->paymentMock->method('getPoNumber') ->willReturn('abc'); $expected = [ 'transactionRequest' => [ 'poNumber' => 'abc' ] ]; $buildSubject = [ 'payment' => $this->paymentDOMock, ]; $this->assertEquals($expected, $this->builder->build($buildSubject)); } }