docs icon indicating copy to clipboard operation
docs copied to clipboard

Documentation does not cover setup of testing database

Open RobQuistNL opened this issue 2 years ago • 2 comments

When we follow the docs nothing states anything about provisioning a testing database.

The phpunit environment will try to use app_test because of the doctrine line dbname_suffix: '_test%env(default::TEST_TOKEN)%' in config/packages/doctrine.yaml

I'm not sure if running docker compose exec php bin/console hautelook:fixtures:load as per the documentation uses this too.

Either way, when we run tests following this documentation: https://api-platform.com/docs/distribution/testing/#writing-functional-tests

the first error we run into is:

$ docker compose exec php php ./vendor/bin/phpunit
Could not open input file: ./vendor/bin/phpunit

When we change that to docker compose exec php php ./vendor/bin/simple-phpunit it runs, but, when we follow the docs on https://api-platform.com/docs/core/testing/#the-test-httpclient with the JWT setup, the first error we run into is the following:

There was 1 error:

1) App\Tests\AuthenticationTest::testLogin
Doctrine\DBAL\Exception\ConnectionException: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "database" (172.18.0.5), port 5432 failed: FATAL:  database "app_test" does not exist

This is not covered by the documentation (and preferably this would be included somewhere in the config / phpunit steps)

RobQuistNL avatar May 09 '23 18:05 RobQuistNL

we're currently reviewing the documentation for this, thanks for the report @Romaixn

soyuka avatar May 10 '23 07:05 soyuka