samedi 12 octobre 2019

How to connect database in codeception lumen?

I already searching on how I'm going connect codeception database in lumen but I failed. I already add the database connection in my config

<?php

return [

    'default' => env('DB_CONNECTION', 'mysql'),

    'connections' => [

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'root'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

        'mysql_test' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => 'mysql_test',
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'root'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

    ],

    'migrations' => 'migrations',
];

and my codeception.yml and I have this code

paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed   
coverage:
    enabled: true
    include:
      - app/config/*.php
      - app/controllers/*.php
      - app/models/*.php
modules:
    enabled:
        - Db:
            dsn: 'mysql:host=localhost;dbname=scheduler_test'
            user: 'root'
            password: 'root'
            dump: tests/_data/dump.sql
            cleanup: true
            populate: false

every time I try to use the database, doing request or test the api. It always the default connection it used.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35zAtF5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire