0、phpunit手册:https://phpunit.de/manual/current/zh_cn/phpunit-book.html
1、读取xml文件
developer-a.xml
?
mytest.php
assertequals(0, count($stack)); array_push($stack, $globals['db_user']); $this->assertequals('root', $stack[count($stack)-1]); //$this->assertequals(1, count($stack)); //$this->assertequals('foo', array_pop($stack)); //$this->assertequals(0, count($stack)); }}?>
?
测试命令:
写道
phpunit --configuration developer-a.xml mytest.php
?
2、例 2.3: 利用测试之间的依赖关系
asserttrue(true); return 'first'; } public function testproducersecond() { $this->asserttrue(true); return 'second'; } /** * @depends testproducerfirst * @depends testproducersecond */ public function testconsumer() { $this->assertequals( array('first', 'second'), func_get_args() ); }}?>
?
测试命令行:
写道
phpunit dependencyfailuretest.html
?
3、php 关联数组关联数组是使用您分配给数组的指定键的数组。
有两种创建关联数组的方法:
$age=array(peter=>35,ben=>37,joe=>43);
?
或者:
$age['peter']=35;$age['ben']=37;$age['joe']=43;
?随后可以在脚本中使用指定键:
35,steve=>37,peter=>43);echo peter is . $age['peter'] . years old.;?>
?