本文整理汇总了PHP中ApiTester::dontSeeResponseContainsJson方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::dontSeeResponseContainsJson方法的具体用法?PHP ApiTester::dontSeeResponseContainsJson怎么用?PHP ApiTester::dontSeeResponseContainsJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::dontSeeResponseContainsJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSinglePost
public function getSinglePost(ApiTester $I)
{
$id = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Starwars']));
$I->sendGET($this->endpoint . "/{$id}");
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['id' => "{$id}", 'title' => 'Starwars']);
$I->dontSeeResponseContainsJson([['id' => $id]]);
}
示例2: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('get a single device');
$piOne = $I->haveRecord('devices', ['ip' => '192.168.1.101', 'mac' => '11:22:33:44:55:66', 'name' => 'Awesome Pi One', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
$piTwo = $I->haveRecord('devices', ['ip' => '192.168.1.102', 'mac' => 'AA:BB:CC:DD:EE:FF', 'name' => 'Awesome Pi Two', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
$I->sendGET('devices/1');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['data' => ['ip' => '192.168.1.101', 'name' => 'Awesome Pi One', 'on_home_page' => 'auto', 'group' => null]]);
$I->seeResponseJsonMatchesXpath('//data//device_added');
$I->seeResponseJsonMatchesXpath('//data//last_contact');
$I->dontSeeResponseContainsJson(['data' => ['ip' => '192.168.1.102', 'name' => 'Awesome Pi Two', 'on_home_page' => 'auto', 'group' => null]]);
$I->sendGET('devices/100');
$I->seeResponseCodeIs(404);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['errors' => ['title' => 'Did not find the device you are looking for!', 'status' => 404]]);
示例3: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('list all devices');
$I->haveRecord('devices', ['ip' => '192.168.1.101', 'mac' => '11:22:33:44:55:66', 'name' => 'Public Pi', 'public' => 'true', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
$piOne = $I->grabRecord('devices', ['ip' => '192.168.1.101']);
$piTwo = $I->haveRecord('devices', ['ip' => '192.168.1.102', 'mac' => 'AA:BB:CC:DD:EE:FF', 'name' => 'Private Pi', 'public' => 'false', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
$piTwo = $I->grabRecord('devices', ['ip' => '192.168.1.102']);
$piThree = $I->haveRecord('devices', ['ip' => '192.168.1.103', 'mac' => 'AA:11:BB:22:CC:33', 'name' => 'Auto Pi without group', 'public' => 'auto', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
$piThree = $I->grabRecord('devices', ['ip' => '192.168.1.103']);
$piFour = $I->haveRecord('devices', ['ip' => '192.168.1.104', 'mac' => 'DD:44:EE:55:FF:66', 'name' => 'Auto Pi with group', 'public' => 'auto', 'group' => 'my-group', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
$piFour = $I->grabRecord('devices', ['ip' => '192.168.1.104']);
$I->sendGET('devices');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['data' => ['ip' => '192.168.1.101', 'name' => 'Public Pi', 'on_home_page' => 'true', 'group' => null, 'device_added' => \Carbon\Carbon::parse($piOne->created_at)->toIso8601String(), 'last_contact' => \Carbon\Carbon::parse($piOne->updated_at)->toIso8601String()]]);
$I->dontSeeResponseContainsJson(['data' => ['ip' => '192.168.1.102', 'name' => 'Private Pi', 'on_home_page' => 'false', 'group' => null, 'device_added' => \Carbon\Carbon::parse($piTwo->created_at)->toIso8601String(), 'last_contact' => \Carbon\Carbon::parse($piTwo->updated_at)->toIso8601String()]]);
$I->seeResponseContainsJson(['data' => ['ip' => '192.168.1.103', 'name' => 'Auto Pi without group', 'on_home_page' => 'auto', 'group' => null, 'device_added' => \Carbon\Carbon::parse($piTwo->created_at)->toIso8601String(), 'last_contact' => \Carbon\Carbon::parse($piTwo->updated_at)->toIso8601String()]]);
$I->dontSeeResponseContainsJson(['data' => ['ip' => '192.168.1.104', 'name' => 'Auto Pi with group', 'on_home_page' => 'auto', 'group' => 'my-group', 'device_added' => \Carbon\Carbon::parse($piTwo->created_at)->toIso8601String(), 'last_contact' => \Carbon\Carbon::parse($piTwo->updated_at)->toIso8601String()]]);
$I->sendGET('devices/@my-group');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['data' => ['name' => 'Auto Pi with group']]);
$I->dontSeeResponseContainsJson(['data' => ['name' => 'Auto Pi without group']]);
$I->dontSeeResponseContainsJson(['data' => ['name' => 'Private Pi']]);
$I->dontSeeResponseContainsJson(['data' => ['name' => 'Public Pi']]);