PHPUnit knowledge point aggregation (continuous update)

Source: Internet
Author: User
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.";?>
?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.