3

If I'm using this YiiPimple for dependency injection, then how to configure bootstrap file for phpunit? Below given bootstrap file content:

$yiit=dirname(__FILE__).'/../../../../../yii-assets/framework/yiit.php';
$config=dirname(__FILE__).'/../config/test.php';
require_once($yiit);
require_once(dirname(__FILE__).'/WebTestCase.php');
require_once(dirname(__FILE__).'/../../../components/WebApplication.php');
Yii::createApplication('WebApplication', $config)->run();

But when I run this phpunit following error occurs:

Fatal error: Uncaught exception 'CHttpException' with message 'Unable to resolve
 the request "site".' in D:\xampp\htdocs\yii-assets\framework\web\CWebApplicatio
n.php:286
Stack trace:
#0 D:\xampp\htdocs\yii-assets\framework\web\CWebApplication.php(141): CWebApplic
ation->runController('')
#1 D:\xampp\htdocs\yii-assets\framework\base\CApplication.php(180): CWebApplicat
ion->processRequest()
#2 D:\xampp\htdocs\AdlugeCore\protected\modules\lead\tests\bootstrap.php(11): CA
pplication->run()
#3 D:\xampp\php\pear\PHPUnit\Util\Fileloader.php(92): include_once('D:\xampp\htd
ocs...')
#4 D:\xampp\php\pear\PHPUnit\Util\Fileloader.php(76): PHPUnit_Util_Fileloader::l
oad('D:\xampp\htdocs...')
#5 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(778): PHPUnit_Util_Fileloader::c
heckAndLoad('D:\xampp\htdocs...')
#6 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(606): PHPUnit_TextUI_Command->ha
ndleBootstrap('D:\xampp\htdocs...')
#7 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(138): PHPUnit_TextUI_Command->ha
ndleArguments(Array)
#8 D:\xampp\php\pear\PH in D:\xampp\htdocs\yii-assets\framework\web\CWebApplicat
ion.php on line 286
Vinu Sebastian
  • 568
  • 3
  • 16

1 Answers1

0

You shouldn't run the application in the phpunit bootstrap file.

Try changing

Yii::createApplication('WebApplication', $config)->run();

To

Yii::createApplication('WebApplication', $config);
David Ipsen
  • 1,513
  • 1
  • 15
  • 22