Unit Test-php function test questions

Source: Internet
Author: User
I used to write several projects and use the golang (revel framework). It is very convenient to write tests in it. For example, to test whether an action works properly: {code ...} now the project uses the phpyii framework and wants to perform such basic tests. No similar method is found. I don't know the http in php... I used to write several projects and use the golang (revel framework). It is very convenient to write tests in it, for example, to test whether an action works properly:

Func (t * UserTest) TestInfo () {// directly access t. get ("/user/info/") // check whether the HTTP code is 200 by default. // check whether the return header is correct. assertContentType ("text/html; charset = UTF-8") // obtain the returned content res: = string (t. responseBody) // compare the returned content to do ...}

Now the project uses the php yii framework and wants to perform such basic tests. No similar method is found.
I don't know how to write and test these http methods in php?

Reply content:

I used to write several projects and use the golang (revel framework). It is very convenient to write tests in it, for example, to test whether an action works properly:

Func (t * UserTest) TestInfo () {// directly access t. get ("/user/info/") // check whether the HTTP code is 200 by default. // check whether the return header is correct. assertContentType ("text/html; charset = UTF-8") // obtain the returned content res: = string (t. responseBody) // compare the returned content to do ...}

Now the project uses the php yii framework and wants to perform such basic tests. No similar method is found.
I don't know how to write and test these http methods in php?

In general, php uses the phpunit test framework for testing.

In fact, the official yii solution also uses phpunit (see here)

Here is a tutorial on how to use it.

Currently, phpunit is a better test.

It is estimated that you want the selenium of phpunit, but it has never been used and cannot provide more help.
Https://netbeans.org/kb/docs/php/phpunit_zh_CN.html#selenium

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.