Skip to content

[Lumen] How can I make sure which configure file codecept read? #7

Closed

Description

@ChangJH-Mark

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 -vvv

under 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.test

and 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:101

as 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?

Activity

  1. changed the title [-]how can I make sure which configure file codecept read?[/-] [+][Lumenhow can I make sure which configure file codecept read?[/+] on Jan 7, 2019
  2. changed the title [-][Lumenhow can I make sure which configure file codecept read?[/-] [+][Lumen] How can I make sure which configure file codecept read?[/+] on Jan 7, 2019
  3. TavoNiievez commented on Jan 12, 2021

    @TavoNiievez
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions