i have set up of php/mysql/apache/laravel stack through the docker without problems, everything up and running. i have set up docker in phpStorm as well- everything works good.
now im trying to set up phpUnit in phpStorm, which i never set up before especially with the docker container so error could be very simple i just cant understand what is wrong and where :(
when i run any test (which is working well for sure) i'm receiving this kind of errors:
it looks like smth is wrong with the DB connection settings but i cant understand what is wrong because the only change from what main application uses is database name and database with this name exists
here is how i set up phpUnit in phpStorm, as you can see the path to the phpunit.xml
is set up and everything look good
here is .env
DB_CONNECTION=mysql
DB_HOST=xcard_db
DB_PORT=3306
DB_DATABASE=xcard
DB_TEST_DATABASE=xcard_test
DB_USERNAME=root
DB_PASSWORD=jackjack
this is laravel config/database.php
, as you can see i use DB_TEST_DATABASE and this is the only difference (i have cleaned some unnecessary settings, errors are the same with or without them)
'xcard_test' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_TEST_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
and here is my phpunit.xml in which i use DB_CONNECTION="xcard_test"
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="xcard_test"/>
<server name="LOG_CHANNEL" value="test"/>
</php>
</phpunit>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire