安装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,表示成功
基本过程结束