Пример #1
0
 public function proxyToGivenUriTest(AcceptanceTester $I)
 {
     $expectation = PhiremockClient::on(A::getRequest()->andUrl(Is::equalTo('/potato'))->andHeader('X-Potato', Is::sameStringAs('bAnaNa'))->andScenarioState('PotatoScenario', 'Scenario.START'))->proxyTo('https://es.wikipedia.org/wiki/Proxy');
     $this->phiremock->createExpectation($expectation);
     $guzzle = new GuzzleHttp\Client();
     $originalBody = $guzzle->get('https://es.wikipedia.org/wiki/Proxy')->getBody();
     $I->haveHttpHeader('X-Potato', 'banana');
     $I->sendGet('/potato');
     $I->seeResponseEquals($originalBody);
 }
Пример #2
0
<?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);
Пример #3
0
<?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');
Пример #4
0
<?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');
Пример #5
0
<?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');
Пример #6
0
<?php

$I = new AcceptanceTester($scenario);
$I->wantTo('test all end points for basic errors');
$endpoints = array('account_addrs', 'accounts', 'attendees', 'cabins', 'cards', 'charges', 'checks', 'employees', 'events', 'fees', 'locations', 'owners', 'owner_numbers', 'payments', 'registrations', 'requests', 'sessions', 'settings', 'users');
foreach ($endpoints as $endpoint) {
    $I->sendGet("{$endpoint}?limit=2");
    $I->seeResponseCodeIs(200);
    $I->seeResponseIsJson();
}
Пример #7
0
<?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");
}