This method can be used by the YII Framework unit test, the latest version of PHPUnit is installed in PHP compressed Phar format
Software: http://pear.phpunit.de/
Note: Packages under the directory need to be placed in the corresponding directory according to the format of the code
1, Mkdir/server/php/pear/phpunit
2, RZ phpunit-3.7.35.tgz
3, TAR-ZXVF phpunit-3.7.35.tgz
4, MV PHPUnit-3.7.35 PHPUnit
5, modify the php.ini
include_path = ".:/ Php/includes:/server/php5/lib/php:/website/external:/server/php5/pear/phpunit "
6. Restart Apahce/server/apache2/bin/apachectl restart
7. The contents of the phpunit.php file under the PHPUnit root directory are as follows:
#!/server/php/bin/php
Define (' Phpunit_main_method ', ' phpunit_textui_command::main ');
Require ' PHPUnit '. Directory_separator. ' autoload.php ';
/*
if (Strpos (' @[email protected] ', ' @php_bin ') = = = 0) {
Require DirName (__file__). Directory_separator. ' PHPUnit '. Directory_separator. ' autoload.php ';
} else {
Require ' @[email protected] '. Directory_separator. ' PHPUnit '. Directory_separator. ' autoload.php ';
}
*/
Phpunit_textui_command::main ();
8, vi/website/book/protected/tests/unit/dbtest.php
<?php
Class DbTest extends Ctestcase
{
Public Function testconnection ()
{
$this->assertnotequals (NULL, Yii::app ()->db);
}
}
?>
8. Test:
Cd/website/book/protected/tests
/server/php/pear/phpunit/phpunit.php unit/dbtest.php
PHPUnit Installation Method