1)安装好Zend Server EC5.3
安装在C:/Program Files/Zend
2)修改C:/Program Files/Zend/ZendServer/bin的go-pear.bat 文件
修改后的内容是:
@ECHO OFF
set PHP_BIN=php.exe
rem %PHP_BIN% -d output_buffering=0 PEAR/go-pear.phar
%PHP_BIN% -d phar.require_hash=0 PEAR/go-pear.phar
pause
set PHP_BIN=php.exe
rem %PHP_BIN% -d output_buffering=0 PEAR/go-pear.phar
%PHP_BIN% -d phar.require_hash=0 PEAR/go-pear.phar
pause
3)双击运行go-pear.bat
4)在cmd窗口下
pear upgrade all
5)安装phpunit
在cmd窗口下
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit
6)修改php.ini
修改php.ini
找到include_path把C:/Program Files/Zend/ZendServer/bin/PEAR加到后面
重启apache
phpunit可以使用了.
7)测试phpunit
新建立test.php放在C:/Program Files/Zend/Apache2/htdocs下面.
test.php的内容:
<?php
class ArrayTest extends PHPUnit_Framework_TestCase {
public function testNewArrayIsEmpty() {
/*Create the Array fixture*/
$fixture = array();
/* Assert that the size of the Array * fixture is 0*/
$this->assertEquals(0, sizeof($fixture));
}
class ArrayTest extends PHPUnit_Framework_TestCase {
public function testNewArrayIsEmpty() {
/*Create the Array fixture*/
$fixture = array();
/* Assert that the size of the Array * fixture is 0*/
$this->assertEquals(0, sizeof($fixture));
}
public function testArrayContainsAnElement() {
/* Create the Array fixture*/
$fixture = array();
/*Add an element to the Array * fixture*/
$fixture[] = 'Element';
/*Assert that the size of the * Array fixture is 1*/
$this->assertEquals(1, sizeof($fixture));
}
/* Create the Array fixture*/
$fixture = array();
/*Add an element to the Array * fixture*/
$fixture[] = 'Element';
/*Assert that the size of the * Array fixture is 1*/
$this->assertEquals(1, sizeof($fixture));
}
}
?>
?>
在cmd窗口下
cd /d C:/Program Files/Zend/Apache2/htdocs
phpunit test.php
可以看到phpunit的测试结果.
PHPUnit 3.5.6 by Sebastian Bergmann.
..
Time: 0 seconds, Memory: 3.00Mb
OK (2 tests, 2 assertions)
..说明测试成功.
把test.php的$this->assertEquals(0, sizeof($fixture));修改为$this->assertEquals(1, sizeof($fixture));
再测试
phpunit test.php
得到的结果
PHPUnit 3.5.6 by Sebastian Bergmann.
F.
Time: 0 seconds, Memory: 3.00Mb
There was 1 failure:
1) ArrayTest::testNewArrayIsEmpty
Failed asserting that <integer:0> matches expected <integer:1>.
Failed asserting that <integer:0> matches expected <integer:1>.
C:/Program Files/Zend/Apache2/htdocs/test.php:7
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
Tests: 2, Assertions: 2, Failures: 1.
说明测试发现有错误.