<?php $I = new AcceptanceTester($scenario); $I->wantTo('test various search examples'); // simple search of child table $I->sendGet('/attendees?page=1&per_page=5'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.attendees[*].id'); // complex search on child table $I->sendGet('/attendees?page=1&per_page=5'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.attendees[*].id'); // simple search of complex table $I->sendGet('/events?page=1&per_page=5'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.events[*].id'); // test with syntax $I->sendGet('/events?page=1&per_page=5&with=cabins,locations,programs,sessions'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.events[*].id'); $I->seeResponseJsonMatchesJsonPath('$.locations[*].id'); $I->seeResponseJsonMatchesJsonPath('$.programs[*].id'); $I->seeResponseJsonMatchesJsonPath('$.cabins[*].id'); $I->seeResponseJsonMatchesJsonPath('$.sessions[*].id'); // test with + single individual syntax $I->sendGet('/events/1?page=1&per_page=5&with=cabins,locations,programs,sessions'); $I->seeResponseCodeIs(200);
<?php $I = new AcceptanceTester($scenario); $I->wantTo('test basic User operations'); // load a subsect of users $I->wantTo('load a group of users'); $I->sendGet('/users?page=1&per_page=5'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.users[*].first_name');
<?php $I = new AcceptanceTester($scenario); $I->wantTo('test basic Account operations'); // load a subsect of accounts $I->wantTo('load a group of accounts'); $I->sendGet('/accounts?page=1&per_page=5'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.accounts[*].created_on');
<?php $I = new AcceptanceTester($scenario); $I->wantTo('test basic Location operations'); // load a subsect of locations $I->wantTo('load a group of locations'); $I->sendGet('/locations?page=1&per_page=5'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.locations[*].name');
<?php $I = new AcceptanceTester($scenario); $I->wantTo('test basic Program operations'); // load a subsect of programs $I->wantTo('load a group of programs'); $I->sendGet('/programs?page=1&per_page=5'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.programs[*].name');
<?php $I = new AcceptanceTester($scenario); $I->wantTo('Test query abilities of all api end points'); $endpoints = array('addresses', 'customers', 'users'); foreach ($endpoints as $endpoint) { $I->sendGet("{$endpoint}?limit=2"); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $newID = $I->grabDataFromResponseByJsonPath("\$.{$endpoint}[0].id"); // test calling an individual resource $I->sendGet($endpoint . '/' . $newID[0]); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); // test offsett $I->sendGet("{$endpoint}?limit=2&offset=2"); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath("\$.{$endpoint}[*].id"); // run searches side loading all records $I->sendGet("{$endpoint}?limit=2&offset=2&with=all"); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath("\$.{$endpoint}[*].id"); // run searches with NO side loaded records $I->sendGet("{$endpoint}?limit=2&offset=2&with=none"); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath("\$.{$endpoint}[*].id"); }