Skip to content
Advertisement

Tag: phpunit

PHPUnit Larvel execute ONCE before testing

I use Laravel 8 with PHPUnit 9.3.3 Now I has written in CreatesApp.php: And this code executes every test and I want this code executed ONLY before testing: Answer If you want to execute some commands only once at startup – you can bootstrap tests with your own boostraper: docs But, your way is not correct: Tests MUST be isolated:

Symfony mocking repository for testing

I’m trying to mock a repository containing all modules, and it has a method called findAll() that returns all elements from that repository. I cant seem to be able to pull any data from the mocked repository. Any ideas how I could fix it? Mocking repository: Trying to use method from ModuleRepository class called findAll() that returns all elements from

Failing to load Xdebug when running PHPUnit Tests

I have been having a option for a few days. When I try to run a PHPUnit test I get a message saying failed to load Xdebug. I have tried to reinstall, change filepaths etc but I am getting nowhere. Hoping somebody can help me out 🙂 Answer Failing loading xxxx.dll is an indication that PHP can’t load the extension

PHPUnit assertDatabaseHas with Laravel and Inertia

I have a Laravel 8 setup that utilises Intertia.js. I’m trying to test my post routes to store new resources and want to assert that the database has the new record stored, using the assertDatabaseHas() method. Controller.php CreateSlotTest.php When I debug the session I can see the slot that I added to the with() method but I can’t figure out

Advertisement