Harlan Gray
Harlan Gray

Reputation: 341

Implementing Codeception with Yii1

I am trying to do unit testing for my project done in Yii1. These are the steps I took

Added composer.json and added the following

{
    "require-dev": {
        "codeception/codeception": "2.3.*",
        "codeception/yii-bridge":"dev-master"
    }
}

and created the complete suit by bootstrapping

In my unit.suit.yml I added

- Yii1:
        appPath: '../index-test.php'
        url: 'http://localhost/pricingdb/index-test.php/'       

In my index-test.php I have

<?php

defined('DS') or define('DS', DIRECTORY_SEPARATOR);

$yii=dirname(__FILE__).'/../../yii-1.1.12.b600af/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/test.php';

defined('YII_DEBUG') or define('YII_DEBUG',true);

require_once($yii);
require_once __DIR__.DS.'vendor'.DS.'autoload.php';

return array(
       'class' => 'CWebApplication',
       'config' => $config,
);

In my config/test.php I have

<?php

return CMap::mergeArray(
                require(dirname(__FILE__) . '/main.php'), array(
            'components' => array(
                'request' => array(
                    'class' => 'CodeceptionHttpRequest'
                ),
            ),
                )
);

When I try to run unit tests from my protected folder with the following command

..\vendor\bin\codecept run unit

I get the following message

In Yii1.php line 173:

  Yii1 module is not configured!

  Codeception-Yii Bridge is not launched. In order to run tests you need to install https://github.com/Codeception/Yi
  iBridge Implement function 'launch_codeception_yii_bridge' to load all Codeception overrides

What am I missing here? What does it mean to "Implement function 'launch_codeception_yii_bridge' to load all Codeception overrides" ? How do I do that?

Upvotes: 0

Views: 809

Answers (1)

Harlan Gray
Harlan Gray

Reputation: 341

I added

require_once __DIR__.'/../../../../vendor/codeception/yii-bridge/yiit.php';

in the Helper/Unit.php and it seems to work now.

Upvotes: 1

Related Questions