paymentDOMock = $this->createMock(PaymentDataObjectInterface::class); $this->paymentMock = $this->createMock(Payment::class); $this->paymentDOMock->method('getPayment') ->willReturn($this->paymentMock); $this->handler = new CloseTransactionHandler(new SubjectReader()); } public function testHandleClosesTransactionByDefault() { $subject = [ 'payment' => $this->paymentDOMock ]; $response = [ 'transactionResponse' => [] ]; // Assert the transaction is closed $this->paymentMock->expects($this->once()) ->method('setIsTransactionClosed') ->with(true); $this->handler->handle($subject, $response); // Assertions are via mock expects above } }