PHPUnit Knowledge Point Aggregation (continuous update)

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

  • 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.