How to create PHPunit tests cases in Netbeans for an Yii web application
Environment
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
-
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.
-
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.
-
Make sure that your Yii framework is added to your PHP Include Path
-
Create a directory for your tests at the same level of protected directory.
-
Copy, to your tests directory, these attached files TestApplication.php, TestWebApplication.php, yii.php.
-
As SiteController.php extends CController, add to SiteController.php this line:
require_once ‘yii.php’;
-
Right clic SiteController.php and select Tools>Create PHPunit tests.
-
Remove from SiteController.php this line added in Step 6 :
require_once ‘yii.php’;
-
In SiteControllerTest setUp(), comment as
//$this->object = new SiteController;
or change this line to$this->object = new SiteController(‘site’);
-
Add this test
testHello() {$this->assertEquals(‘Hello’, ‘Hello’);}
-
Right click SiteController.php and select Test (or Ctrl+F6). that's all.