PHPunit tests cases in Netbeans for an Yii web application

How to create PHPunit tests cases in Netbeans for an Yii web application


  Product Version: NetBeans IDE Dev (Build 200903111543)

  Java: 1.6.0_10; Java HotSpot� Client VM 11.0-b15

  System: Windows XP version 5.1 running on x86; Cp1252; es_ES (nb)

  Apache 2.2.6 / PHP 5.2.4

  Yii framework 1.0.3

  PHPunit test 3.3.15

  1. Create a web application project with yiic tools (e.g. yii-1.0.3.r780\framework>yiic webapp …/…/testdrive2). Run the project to see that it works.

  2. Create a netbeans php project from the source code obtained (File>New Project>Categories:PHP>Projects: PHP Application with Existing Sources). Run the project to see that it works.

  3. Make sure that your Yii framework is added to your PHP Include Path

  4. Create a directory for your tests at the same level of protected directory.

  5. Copy, to your tests directory, these attached files TestApplication.php, TestWebApplication.php, yii.php.

  6. As SiteController.php extends CController, add to SiteController.php this line:

    require_once ‘yii.php’;
  7. Right clic SiteController.php and select Tools>Create PHPunit tests.

  8. Remove from SiteController.php this line added in Step 6 :

    require_once ‘yii.php’;
  9. In SiteControllerTest setUp(), comment as

    //$this->object = new SiteController;
    or change this line to
    $this->object = new SiteController(‘site’);
  10. Add this test

    testHello() {$this->assertEquals(‘Hello’, ‘Hello’);}
  11. Right click SiteController.php and select Test (or Ctrl+F6). that's all.



Unfortunately I am not able to download the files. Any possibility to fix it?

best regards and thx,


I also cannot download the file.

someone help.

No funciona la descarga de ninguno de los tres archivos adjuntos, podrías volver a adjuntarlos.

Un saludo y gracias.

Ya no son necesarios. ¿Qué problemas tienes?

También puedes ver estas referencias:

the links are broken…