0

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?

1 Answer 1

1

I added

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

I'd put require_once __DIR__.DS.'vendor'.DS.'codeception'.DS.'yii-bridge'.DS.'yiit.php'; after autoloads line inside index-test.php
Yep that's clean. Just found my solution in some post. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.