phpunit安裝方式

來源:互聯網
上載者:User

標籤: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安裝方式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.