您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 抚顺分类信息网,免费分类信息发布

PHPUnit知识点集聚(持续更新)

2025/3/19 7:27:12发布13次查看
phpunit知识点汇聚(持续更新)
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.;?>
?
抚顺分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录