centos --- phpunit 安裝過程


安裝pear 的命令如下:
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar

pear 安裝成功!


下面用 pear 來安裝phpunit


pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com

pear upgrade-all
pear install phpunit/PHPUnit

在安裝的過程中可能會出現依賴包,按照提示信息進行安裝。
如:yum install php-dom -y等
例子:a.php
<?php
class StackTest extends PHPUnit_Framework_TestCase
{
    public function testPushAndPop()
    {
        $stack = array();
        $this->assertEquals(0, count($stack));
        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));
        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
?>
phpunit a.php 看到OK,表示成功
基本過程結束
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章