我是Codeception的新手,我正在尝试使用相同的方式测试我的Web服务。现在我正在试图弄清楚如何深入挖掘并测试来自不同API点的输出。例如,我正在尝试创建用户并检查响应是否包含必要的详细信息。
CreateUserCept.php
<?php
$faker = Faker\Factory::create();
$I = new ApiTester($scenario);
$I->wantTo('create a new user');
$I->haveHttpHeader('Authorization', 'Bearer ' . file_get_contents('tests/api/token'));
$I->sendPost('users', [
"first_name" => "Test",
"last_name" => "Test",
"email" => 'test@test.com',
"password" => "testing",
"role" => "1"
]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
响应类似于:
{
"status": "success",
"data": {
"first_name": "Test",
"last_name": "Test",
"email": "test@test.com",
"updated_at": "2015-11-12 09:08:31",
"created_at": "2015-11-12 09:08:31",
"id": 54
},
"errors": null,
"message": "Resource Created Successfully"
}
现在我可以做一些断言:
$I->seeResponseContainsJson(['status' => 'success']);
它就像一个魅力,但当我这样做时:
$I->seeResponseContainsJson(['data.first_name' => 'Test']);
失败了。深入研究这些并检查JSON响应的正确方法是正确的吗?
答案 0 :(得分:2)
这最终对我有用:
@media only screen and (max-height:1080px){
#wrapper {
width: 1884px;
height: 1080px;
float: left;
}
.filter-selection ul li
{
height:109px;
}
}
@media only screen and (max-height:1000px){
#wrapper {
width: 1884px;
height: 1000px;
float: left;
}
.filter-selection ul li
{
height:106px;
}
}