dongwei8440 2016-10-18 22:09 采纳率: 100%
浏览 66
已采纳

启用Yii1模块的代码

I am using codeception 2.2.5 aand Yii 1.1.4 I have the issue with the Yii1 module. I have it configured for functional and unit tests

Here is the functional.suite.yml

class_name: FunctionalTester
modules:
    enabled:
        - Yii1:
            appPath: 'www/test.php'
            url: 'http://localhost/test.php'
            part: init
        - PhpBrowser:
            url: 'http://localhost/index-test.php'
        - \Helper\Functional
coverage:
    enabled: true
    remote: false

Here is the unit.suite.yml

class_name: UnitTester
modules:
    enabled:
        - Asserts
        - Yii1:
            appPath: 'www/test.php'
            url: 'http://localhost/test.php'
        - \Helper\Unit

When I run the tests separately everything works great. e.g.

php codecept.phar run functional --xml --html
php codecept.phar run unit --xml --html

When I run all together

php codecept.phar run --xml --html

It runs the functional without the issue connected with the Yii1 module. And on the unit it brings

[Codeception\Exception\ModuleConfigException]                     
  Yii1 module is not configured!                                    

  Couldn't load application config file www/test.php                
  Please provide application bootstrap file configured for testing

The main goal to run all together is the code coverage.

  • 写回答

1条回答 默认 最新

  • douzhang8840 2016-11-07 05:38
    关注

    Here is the answer to my problem:

    I created a separate module Yii1Ext(Yii1Ext.php) which extends to Yii1 module:

    namespace Helper;
    
    use Codeception\Module\Yii1;
    
    class Yii1Ext extends Yii1
    {
        public function _initialize()
        {
            $this->config['appPath'] = FRONTEND.'/'.$this->config['appPath'];
            parent::_initialize();
        }
    }
    

    And in configuration files have the Yii1Ext module enabled instead of Yii1 module

    class_name: FunctionalTester
    modules:
        enabled:
            - \Helper\Yii1Ext:
                appPath: 'www/test.php'
                url: 'http://localhost/test.php'
                part: init
            - PhpBrowser:
                url: 'http://localhost/'
    

    Note: Make sure all defined variables in Yii are defined by the statement

    defined('ROOT_DIR') or define('ROOT_DIR', realpath(__DIR__ . '/../'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度