Skip to content
Advertisement

Tag: phpunit

Laravel. Tests clear the active DB

The tables in my active DB are empty after tests. I have the test environment variable DB_CONNECTION=mysql_testing. When I run my tests and do dd(env(‘DB_CONNECTION’)) – everything is fine. I see ‘mysql_testing’. But when I write dd( DB::connection()->getDatabaseName()) I see the wrong DB name(for example ‘db_name’, but it should be ‘testing_db_name’) . It is the name of the active DB.

How to pass arguments to custom composer script

In my Laravel project, I want to run phpunit for a single file, like this one: Here is my composer setup: However, I’m running into this error: www@287dd7480e22:/var/www$ composer run-script test tests/Unit/Services/OrderServiceTest.php php artisan config:cache –env=testing ‘tests/Unit/Services/OrderServiceTest.php’ Too many arguments, expected arguments “command”. Notice: I’ve seen this post: How do you pass an argument to a composer script from the

Reload database before some test in phpunit

I’m currently developing unit tests with phpunit, and symfony 5. On a previous job using behat, we were able to reload the database only for the tests having a specific tag. I’d like to do something similar. I know there is the setUp() method and the @before annotation, but they don’t let me do thing for some tests and not

PHPUnit Stalling in CI

We’re having an issue with PHPUnit sometimes failing to correctly run our test suite in CI. The behaviour manifests as roughly 1/3 tests failing to start and the CI step timing out. Interestingly enough, we don’t see this behaviour: Locally on our machines Every time we run the tests Occur with the dusk tests Our setup is to run the

Advertisement