Laravel 4 codeception laravel迁移采用凭证形式app/testing/database.php,而不是codeception.yml

Laravel 4 codeception laravel迁移采用凭证形式app/testing/database.php,而不是codeception.yml,laravel-4,phpunit,codeception,Laravel 4,Phpunit,Codeception,我注意到codeception中有一个strage行为: 如果我仅依赖codeception.yml,则: actor: Tester paths: tests: tests log: tests/_output data: tests/_data helpers: tests/_support settings: bootstrap: _bootstrap.php colors: true memory_limit: 1024M modu

我注意到codeception中有一个strage行为: 如果我仅依赖codeception.yml,则:

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    helpers: tests/_support
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
modules:
    config:
        Db:
            dsn: 'mysql:host=localhost;dbname=test'
            user: 'test'
            password: 'test'
            dump: tests/_data/dump.sql
运行:

php artisan migrate--package=cartalyst/sentry--env=“testing”php artisan迁移--种子--env=“测试”

我犯了这个错误

[PDO例外]
SQLSTATE[42000][1044]拒绝用户“”@'localhost'访问 数据库“forge”

如果我将database.php文件放在app/config/testing中 与

没关系


我是codeception的新手,所以我想知道是怎么回事,如果我做错了什么。

所以数据库访问有两个方面:

  • 从你的申请中
  • 直接从codeception
  • 来自您的应用程序:

    运行测试时,应用程序需要作为代码的一部分访问数据库。i、 e.当您搜索当前用户,或添加新博客文章等时,此数据库访问将在“测试”模式下通过Laravel进行-因此定义“测试”数据库(您已经完成)是一种良好的做法

    直接从codeception:

    在运行测试时,每个测试之前/之后的数据库必须相同,这一点很重要。这样,测试就不依赖于以前测试的输出等。Codeception将使用yaml文件中定义的数据库访问直接访问数据库,并在每次测试之间使用
    tests/\u data/dump.sql
    文件“刷新”数据库


    Codeception在实际测试期间(就在测试之前/之后)不使用“直接”数据库访问。

    运行迁移时,您正在将环境设置为“测试”,因此需要相应的数据库配置进行测试。您似乎已经回答了自己的问题?我已经阅读了《laravel testing decoded》一书,书中指出要填充测试数据库,您应该运行php artisan migrate--seed--env=“testing”,但我等待对codeception.yml的调用,而不是对database.phpThanks的调用,以获得回复。因此,您说的是等待行为,是吗?是的,这是正确的行为,以及codeception和过程是如何工作的
    return array(
    
        'default' => 'mysql',
    
            'connections' => array(
    
            'mysql' => array(
                'driver'    => 'mysql',
                'host'      => 'localhost',
                'database'  => 'lama-test',
                'username'  => 'lama-test',
                'password'  => 'lama-test',
                'charset'   => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix'    => '',
            )
    
        ),