標籤:des http os io 使用 ar 檔案 art cti
此方法可以使用yii架構的單元測試,最新版本phpunit的安裝方式是php壓縮的phar的格式
軟體:http://pear.phpunit.de/
備忘:目錄下的軟體包需要按照代碼的格式分別放在相對應的目錄下
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、修改php.ini
include_path = ".:/php/includes:/server/php5/lib/php:/website/external:/server/php5/pear/PHPUnit"
6、重啟apahce /server/apache2/bin/apachectl restart
7、phpunit根目錄下的phpunit.php檔案內容如下:
#!/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、 測試:
cd /website/book/protected/tests
/server/php/pear/PHPUnit/phpunit.php unit/DbTest.php
phpunit安裝方式