Repository navigation
Closed
Description
correctly run codeception with configure file
[Doctrine\DBAL\Driver\PDOException] SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge'
Details
- Framework: Laravel Framework Lumen (5.7.6) (Laravel Components 5.7.*)
- Codeception version: Codeception 2.5.1
- Operating System: linux
- Installation type: Composer
I have two codecept installed in machine, one of them was installed by composer. when I run
$ codecept run unit App/ZtTransformerTest -vvvunder ProjectRoot/ it shows
==== Redirecting to Composer-installed version in vendor/codeception ====
Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 7.5.1 by Sebastian Bergmann and contributors.
Running with seed: my ProjectRoot/tests/unit.suite.yml is like
# 5 actor: UnitTester
6 modules:
7 enabled:
8 - Asserts
9 - \Helper\Unit
10 - Lumen:
11 bootstrap: Application/Api/bootstrap/app.php
12 environment_file: Application/Api/.env.testand under ProjectRoot/Application/Api/ there exists a file .env.test
15 # event store DB 主库
16 DB_CONNECTION=mysql
17 DB_ZKNAME=********
18 DB_HOST=*******
19 DB_PORT=******
20 DB_DATABASE=******
21 DB_USERNAME=******
22 DB_PASSWORD=*******I'm sure the database configuration is completely right. But it still report that error. So I add a statement
dd(env('DB_HOST'));in ProjectRoot/Application/Api/config/database.php it's like
dd(env('DB_HOST'));
return [
'migrations' => 'migrations',
'default' => 'mysql',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'zkname' => env('DB_ZKNAME', ''),
'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', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],But when I run codecept again it report
==== Redirecting to Composer-installed version in vendor/codeception ====
Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 7.5.1 by Sebastian Bergmann and contributors.
Running with seed:
Unit Tests (1) --------------------------------------------------------------------------------------------
- ZtTransformerTest: Some featurenull
PHP Fatal error: Uncaught RuntimeException: Command Did Not Finish Properly in ProjectRoot/vendor/codeception/codeception/src/Codeception/Subscriber/ErrorHandler.php:101as you can see the dd print "null" to screen which means .env.test file does not work, I wonder how can I make the codecept read configure file correctly?
Metadata
Metadata
Assignees
Labels
No labels
Activity
Naktibalda commentedon Jan 7, 2019
Lumen module has no
environment_fileoption, it is specific to Laravel5 module.https://codeception.com/docs/modules/Lumen
https://codeception.com/docs/modules/Laravel5
You are welcome to implement it for Lumen.
Laravel5 reads environment file in connector: https://github.com/Codeception/Codeception/blob/cc739e8a049309842e88d8f5389f47826549ca7f/src/Codeception/Lib/Connector/Laravel5.php#L231-L238
[-]how can I make sure which configure file codecept read?[/-][+][Lumenhow can I make sure which configure file codecept read?[/+][-][Lumenhow can I make sure which configure file codecept read?[/-][+][Lumen] How can I make sure which configure file codecept read?[/+]TavoNiievez commentedon Jan 12, 2021
An even older issue is already open requesting this feature, since that would fix this issue, I'm going to close this in favor of #9.