PHPUnit Knowledge Point Aggregation (continuous update)
0, PHPUnit Manual:https://phpunit.de/manual/current/zh_cn/phpunit-book.html
1. Read the XML file
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));} }? >
?
Test command:
Wrote
PHPUnit--configuration Developer-a.xml mytest.php
?
2. Example 2.3: Use the dependency between tests
Asserttrue (true); return ' first '; } Public Function Testproducersecond () { $this->asserttrue (true); return ' second '; } /** * @depends testproducerfirst * @depends testproducersecond * * Public function Testconsumer () { $this->assertequals ( ' first ', ' second '), Func_get_args ())} }? >
?
To test the command line:
Wrote
PHPUnit dependencyfailuretest.html
?
3. PHP Associative array
An associative array is an array that uses the specified key that you assign to the array.
There are two ways to create an associative array:
$age =array ("Peter" and "a", "Ben" = "Notoginseng", "Joe" and "43");
?
or:
$age [' Peter ']= '; $age [' Ben ']= "Notoginseng"; $age [' Joe ']= "43";
? you can then use the specified key in the script:
"A", "Steve" and "Notoginseng", "Peter" and "" "," echo "Peter is. $age [' Peter ']. "Years old.";? >
?