Unit Test-PHP Functional test questions

Source: Internet
Author: User
Originally wrote a few projects, using Golang (Revel framework), it is very convenient to write tests, such as testing whether an action can work properly:

func (t *UserTest) TestInfo(){    //直接访问    t.Get("/user/info/")    //默认较验httpcode 是不是200    //较验返回头是否正确    t.AssertContentType("text/html; charset=utf-8")    //获取返回内容    res := string(t.ResponseBody)    //可以对返回内容进行较验    todo...}

Now the project uses the PHP Yii framework, but also want to do such a basic test, did not find a similar method ah.
I don't know how these HTTP methods in the big god PHP usually write tests?

Reply content:

Originally wrote a few projects, using Golang (Revel framework), it is very convenient to write tests, such as testing whether an action can work properly:

func (t *UserTest) TestInfo(){    //直接访问    t.Get("/user/info/")    //默认较验httpcode 是不是200    //较验返回头是否正确    t.AssertContentType("text/html; charset=utf-8")    //获取返回内容    res := string(t.ResponseBody)    //可以对返回内容进行较验    todo...}

Now the project uses the PHP Yii framework, but also want to do such a basic test, did not find a similar method ah.
I don't know how these HTTP methods in the big god PHP usually write tests?

In general, PHP is used in unit testing, most of which are tested using the PHPUnit test framework.

In fact, the official Yii recommended program is also used PHPUnit (see here)

How to use it, here is a tutorial

Now the better test is still phpunit

I guess you want PHPUnit's selenium, but it didn't work.
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.