Namespace that seems it doesn’t exist is working but why?

I have this exercice folder that gave me instructions on how to install the web application: So this folder contains a .sh file that installs the necessary things: npm install curl -o phpunit -L https:…

Unable to locate factory for [LaravelPassportClient]

I have a laravel app with passport installed to manage api auth. I’m trying to write some tests but I’m unable to create a Client as per the docs on laravel. I’ve googled similar SO answers but they …

How to use expectException in PHPUnit?

I’m trying to test my Exception, or any other exception in PHP Unit. <?php declare(strict_types=1); namespace TestsException; use PHPUnitFrameworkTestCase; class DrinkIsInvalidExceptionTest …

How to “mock” Sentry client in the PHPUnit tests

In case if you need to test PHP application error handlers, you have to “mock” or just disable sending errors on remote servers in the Sentry client. What is the right way to do this?

Problem in testing with withConsecutive()

I have a class FillUserPaymentStatisticService with methods: public function fillStatisticForAllTime(): void { $firstDate = DateTime::createFromFormat(‘Y-m-d H:i:s’, $this->…

Bypass SIMPLETEST_BASE_URL in PHPUnit.xml

Is there any way to run PHPUnit test case without SIMPLETEST_BASE_URL. I need to perform PHPUnit in an environment where only PHP cli is availabe. So can’t put any url on SIMPLETEST_BASE_URL in …

Laravel eager loading phpunit testing

I am trying to do a GET request to retrieve a specific film via the id /GET ‘film/{id}’ etc film_table — id — description this is what is part of the response, what if I’ve many-to-many …

PHpUnit with xdebug Breaks at BaseTestRunner instead of the actual test

I have setup Xdebug remote debugging with the following configuration: I placed a breakpoint in my phpunit test:

How to assert 2 directories are identical in PHPunit?

I have 2 directories, multiple files, basically text formats. They should be equal. I need to know what files are missing/extra (diff will). What method should I use?

How to test a Symfony BinaryFileResponse with php-unit

I have written an action which create a temporary file and returned it with a BinaryFileResponse and delete it after. Something like this : $response = new BinaryFileResponse($this->getFile($…