Are you running the command from inside the container? If not, then your need to.
Oct 22, 2021
16
Level 1
Having issue running a test on docker
I'm using docker for my laravel and I'm trying to run php artisan test , but when I do I get this error
could not translate host name "pgsql" to address: Temporary failure in name resolution (SQL: select tablename from pg_catalog.pg_tables where schemaname in ('public'))
this is what I have in my .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:1SVdFc4F7c8IoufSvE/qtpjct7LOX5ewJGB/wBD3r1w=
APP_DEBUG=true
APP_URL=http://localhost
DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
DB_DATABASE=laravelDB
DB_USERNAME=laravelDB
DB_PASSWORD=password
TEST_DB_HOST=pgsql
TEST_DB_DATABASE=laravelDB
TEST_DB_USERNAME=laravelDB
TEST_DB_PASSWORD=password
BROADCAST_DRIVER=pusher
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=eu
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_CUSTOMER_NAME="${CUSTOMER_NAME}"
my phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Business">
<directory suffix="Test.php">./business/Reporting</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./Modules/**/Tests/Unit</directory>
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./Modules/**/Tests/Feature</directory>
<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="redis"/>
<server name="DB_CONNECTION" value="pgsql"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
<server name="DB_HOST" value="pgsql"/>
</php>
</phpunit>
Please or to participate in this conversation.