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