Netbeans (6.8), PHPunit and Yii

Nope, I deleted all relations and still the same… :confused:

On second thought I recall my problem was session-related (Yii::app->user).

May help somebody else, though.

/Tommy

Hi again everyone,

Unfortunately I didnt manage to run PhpUnit with Yii… there’s one thing that cant get off my mind - how do you able to write/run model tests without creating Yii application with db config?

Try this:

  1. Comment in bootstarp.php this line:

//require_once(dirname(__FILE__).'/TestApplication.php');

  1. Change setUp() to:

protected function setUp() {


        $this->db = new CDbConnection('mysql:host=localhost;port=3306;dbname=db_name','user','password');

        $this->db->active=true;

        CActiveRecord::$db=$this->db;

        $this->object = new Country;

}

Thx abajja, as always first to answer - now everything works :)

There’s useful!

nice… share. thanks

nice… thanks for sharing… :D

This information is very useful. So far, I was avoiding UnitTest But I’ll work from today itself. I am excited!!!

I also having some issues with PHPUnit / Netbeans / Yii .

When i right click on a model and choose "Create PHPUnit Test" i get the following error :

PHPUnit Skeleton Generator 1.2.0 by Sebastian Bergmann.

Fatal error: Class ‘CActiveRecord’ not found in C:\xampp\htdocs\cbdb\protected\models\Type.php on line 19

Call Stack:

0.0002     125368   1. {main}() C:\xampp\php\phpunit-skelgen:0


0.0039     237776   2. SebastianBergmann\PHPUnit\SkeletonGenerator\Command::main() C:\xampp\php\phpunit-skelgen:45


0.0108     581264   3. ReflectionClass->newInstanceArgs() C:\xampp\php\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171


0.0108     581552   4. SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator->__construct() C:\xampp\php\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171


0.0114     591632   5. include_once('C:\xampp\htdocs\cbdb\protected\models\Type.php') C:\xampp\php\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator.php:125

Hello CVP,

Did you solve this issue??

Unfortunately no - However i am using a newer version of Netbeans and PHP Unit. Maybe i should post a new thread about this.

Hi, i have the same issue with yii, netbeans7.2 and phpunit.

I am also having the exactly same problem. Looking forward to seeing someone who can help!

I think the problem in this case is wrongly specified bootstrap file. Skeleton generation need to know paths and other stuff to be able to read classes.

I guess you have this file, because otherwise you would get RuntimeException that skeleton generator was not able to found it, but probably it’s not setting necessary things - either setting include_paths or explicitely including files like yiilite which contains all those necessary classes.

Same problem.

Netbeans 7.3

yii 1.1.13


PHP Fatal error:  Class 'CActiveRecord' not found in /var/www/demo-yii/protected/models/Customer.php on line 14

PHPUnit Skeleton Generator 1.2.0 by Sebastian Bergmann.

My bootstrap.php file contains:


<?php


// change the following paths if necessary

$yiit=dirname(__FILE__).'/../../../yii-1.1.13/framework/yiit.php';

$config=dirname(__FILE__).'/../config/test.php';


require_once($yiit);

require_once(dirname(__FILE__).'/WebTestCase.php');


Yii::createWebApplication($config);

What is wrong? Any help will be welcome!

Hej guys.

Please Look here:

github dot com/yiisoft/yii/issues/1110:

Add this line to your bootstrap file:

require_once($yiit);

require_once( Yii::getPathOfAlias(‘system.test.CTestCase’).’.php’ );

require_once(dirname(FILE).’/WebTestCase.php’);

And in project properties under PHPUnit configuration make sure that "Use Bootstrap for Creating New Unit Tests" check box is thickened.

very helpful thankyou

In model Type add

require_once (’/../../../../yii/framework/yii.php’); //Path yii

Thanks for sharing, I will definitely look into this.