用pear來安裝phpunit

安裝pear 的命令以下:php

$ wget http://pear.php.net/go-pear.phardom

$ php go-pear.pharthis

pear 安裝成功!.net

下面用 pear 來安裝phpunitcomponent

pear channel-discover pear.phpunit.desymfony

pear channel-discover components.ez.noget

pear channel-discover pear.symfony-project.comit

pear upgrade-allio

pear install phpunit/PHPUnitfunction

在安裝的過程當中可能會出現依賴包,按照提示信息進行安裝。

如: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,表示成功

基本過程結束

相關文章
相關標籤/搜索