PHPUnit knowledge point aggregation (continuous update) 0, PHPUnit Manual: phpunit.demanualcurrentzh_cnphpunit-book.html 1, read XML file developer-a.xml & lt ;? Xmlversion1.0encodingUTF-8? & Gt; & lt; phpunit & gt; PHPUnit knowledge point aggregation (continuous update)
0, PHPUnit Manual: https://phpunit.de/manual/current/zh_cn/phpunit-book.html
1. read XML files
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:
Write
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( array('first', 'second'), func_get_args() ); }}?>
?
Test Command line:
Write
Phpunit DependencyFailureTest.html
?
3. PHP associated array
An associated array is an array that uses the specified key that you assign to the array.
There are two ways to create an associated array:
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
?
Or:
$age['Peter']="35";$age['Ben']="37";$age['Joe']="43";
? You can then use the specified key in the script:
"35","Steve"=>"37","Peter"=>"43");echo "Peter is " . $age['Peter'] . " years old.";?>
?