Yii Testing

Facebook Twitter
Testing: Overview Testing is an indispensable process of software development. Whether we are aware of it or not, we conduct testing all the time when we are developing a Web application. For example, when we write a class in PHP, we may use some echo or die statement to show that we implement a method correctly; when we implement a Web page containing a complex HTML form, we may try entering some test data to ensure the page interacts with us as expected. More advanced developers would write some code to automate this testing process so that each time when we need to test something, we just need to call up the code and let the computer to perform testing for us. Testing: Overview
YAML
NetBeans IDE for PHP supports PHPUnit automated tests. Thanks to PHPUnit, NetBeans IDE provides code coverage for PHP, similar to the code coverage the IDE provides for Python. Test output appears in the same feature-rich output window that the IDE's JUnit and Python test runners use. PHPUnit and Selenium PHPUnit and Selenium
Functional Testing Before reading this section, it is recommended that you read the Selenium documentation and the PHPUnit documentation first. We summarize in the following the basic principles of writing a functional test in Yii: Like unit test, a functional test is written in terms of a class XyzTest which extends from CWebTestCase, where Xyz stands for the class being tested. Because PHPUnit_Extensions_SeleniumTestCase is the ancestor class for CWebTestCase, we can use all methods inherited from this class.The functional test class is saved in a PHP file named as XyzTest.php. Functional Testing
Look up a class, method, property or event CWebTestCase is the base class for Web-based functional test case classes. It extends PHPUnit_Extensions_SeleniumTestCase and provides the database fixture management feature like CDbTestCase. Public Properties CWebTestCase CWebTestCase
README.md PHPUnit PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks. Installation We distribute a PHP Archive (PHAR) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file: PHPUnit

PHPUnit

Automated tests need to be executed many times. To ensure the testing process is repeatable, we would like to run the tests in some known state called fixture. For example, to test the post creation feature in a blog application, each time when we run the tests, the tables storing relevant data about posts (e.g. the Post table, the Comment table) should be restored to some fixed state. The PHPUnit documentation has described well about generic fixture setup. In this section, we mainly describe how to set up database fixtures, as we just described in the example. Setting up database fixtures is perhaps one of the most time-consuming parts in testing database-backed Web applications. Fixtures Fixtures
CDbFixtureManager CDbFixtureManager Look up a class, method, property or event CDbFixtureManager manages database fixtures during tests. A fixture represents a list of rows for a specific table. For a test method, using a fixture means that at the beginning of the method, the table has and only has the rows that are given in the fixture.
Unit Testing Unit Testing Because the Yii testing framework is built on top of PHPUnit, it is recommended that you go through the PHPUnit documentation first to get the basic understanding on how to write a unit test. We summarize in the following the basic principles of writing a unit test in Yii: A unit test is written in terms of a class XyzTest which extends from CTestCase or CDbTestCase, where Xyz stands for the class being tested. For example, to test the Post class, we would name the corresponding unit test as PostTest by convention. The base class CTestCase is meant for generic unit tests, while CDbTestCase is suitable for testing active record model classes. Because PHPUnit_Framework_TestCase is the ancestor class for both classes, we can use all methods inherited from this class.The unit test class is saved in a PHP file named as XyzTest.php.
CTestCase
CDbTestCase CDbTestCase Look up a class, method, property or event CDbTestCase is the base class for test cases about DB-related features. CDbTestCase provides database fixture management with the help of CDbFixtureManager.
Netbeans, PHPunit and Yii Netbeans, PHPunit and Yii How to create PHPunit tests cases in Netbeans 6.8 for an Yii web application Ref.:http://www.yiiframew...ndpost&pid=6301 Environment: Product Version: NetBeans IDE Dev (Build 200909221401) 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 (Win32) PHP/5.2.9-2 Yii framework 1.0.9 PHPUnit 3.3.15 1.
DB Mocking

This page is created to supply short directions and general tips for managing a Yii application in NetBeans IDE. 1. Code completion ¶ To get context sensitive code completion, follow these steps: Include Yii folder (assuming it is properly placed outside project directory) Open "File > Project properties > PHP Include Path" and add the Yii framework root pathIgnore yiilite.php to avoid doubled/missing documentation Open "Tools > Options > Miscellaneous > Files"Add to the front of "Files Ignored by the IDE" the file "^(yiilite\.php|CVS|SCCS|...."Restart NetBeansCode completion in view files Add the following PHPDoc statement at the head of the file to use code completion in view files. NetBeans IDE and Yii projects