我使用Laravel 5和Codeception,我想使用内存中的SQLite数据库进行单元测试,但是,我似乎无法将我的环境设置为"测试& #34;在Codeception中。我使用的是Laravel5模块,并在unit.suite.yml文件中定义了以下内容:
class_name: UnitTester
modules:
enabled: [Asserts, UnitHelper, Laravel5]
config:
Laravel5:
environment_file: .env.testing
我有一个.env文件,它定义了我的所有本地设置,然后是.env.testing文件,它定义了所有特定于测试的设置。但是,它似乎从未真正正确地设置环境。
为了测试我刚刚做过的环境:
$this->assertEquals('testing', \App::environment());
我总是得到:
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'testing'
+'local'
任何人都知道我做错了什么?
答案 0 :(得分:4)
您是否在.env.testing
文件中设置了环境名称?
APV_ENV=testing
答案 1 :(得分:3)
这可能是因为您在全局代码配置中定义了env文件。在项目根目录的codeception.yml文件中检查params的值,应该类似于
params:
- .env.testing