dsvyc66464 2016-04-29 10:38
浏览 138

使用Codeception设置进行Yii2 /高级应用程序单元测试

I have a Yii2 site with Yii2 Advanced Project Template. U have to test the application.

My unit tests works unlett I try to test something that uses database.

The response I got is this:

1) models\XmlTest::testRootError yii\base\InvalidConfigException: Unknown component ID: db

I had created the test database and the tables. I have the same db/app with Simple project template and my tests works fine but when I want to use those in my advanced template, i got those errors.

I hade googled, search solutions in google and here also, but didn't found anything.

Can you please suggest me something about this?

Directory structure:
backend/
common/
console/
environments/
frontend/
tests/
tests/codeception/
tests/codeception/_output/
tests/codeception/backend/
tests/codeception/bin/
tests/codeception/common/
tests/codeception/config/
tests/codeception/console/
tests/codeception/frontend/
vendor/

/tests/codeception/config/config.php:

<?php
/**
 * Application configuration for all backend test types
 */
return [
'components' => [
    'db' => [
        'dsn' => 'mysql:host=localhost;dbname=app_test',
    ],
    'mailer' => [
        'useFileTransport' => true,
    ],
    'urlManager' => [
        'showScriptName' => true,
    ],
],
];
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了