예제 #1
0
 public function testGet()
 {
     $this->module->sendGET('/rest/user/');
     $this->module->seeResponseIsJson();
     $this->module->seeResponseContains('davert');
     $this->module->seeResponseContainsJson(array('name' => 'davert'));
 }
예제 #2
0
 public function testDontSeeInJson()
 {
     $this->module->response = '{"ticket": {"title": "Bug should be fixed", "user": {"name": "Davert"}}}';
     $this->module->seeResponseIsJson();
     $this->module->dontSeeResponseContainsJson(array('name' => 'Davet'));
     $this->module->dontSeeResponseContainsJson(array('user' => array('name' => 'Davet')));
     $this->module->dontSeeResponseContainsJson(array('user' => array('title' => 'Bug should be fixed')));
 }
예제 #3
0
 public function testStructuredJsonPathAndXPath()
 {
     $this->module->response = '{ "store": {"book": [{ "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": {"color": "red", "price": 19.95 } } }';
     $this->module->seeResponseIsJson();
     $this->module->seeResponseJsonMatchesXpath('//book/category');
     $this->module->seeResponseJsonMatchesJsonPath('$..book');
     $this->module->seeResponseJsonMatchesJsonPath('$.store.book[2].author');
 }
예제 #4
0
 function apiAgencyRegistration()
 {
     $agencyOfficeRegion0 = $this->getRegion(21);
     $agencyOfficeCity0 = $this->getCity(4);
     $agencyOfficeAddress0 = $this->getStreetNameById(1);
     $agencyOfficeRegion1 = $this->getRegion(21);
     $agencyOfficeCity1 = $this->getCity(4);
     $agencyOfficeAddress1 = $this->getStreetNameById(1);
     $this->restModule->haveHttpHeader('Content-Type', 'application/json');
     $this->restModule->sendPOST('/registration/agency', ['name' => User::$agencyName, 'subdomain' => User::uniqueSubdomain(), 'firstName' => User::$agencyfirstName, 'lastName' => User::$agencylastName, 'email' => User::uniqueApiAgencyEmail(), 'plainPassword' => User::$agencyRegPass, 'description' => User::$agencyDescription, 'logo' => User::getAgencyLogo(), 'userAvatar' => User::getAgencyAvatar(), 'offices' => [array('officeName' => User::$agencyOfficeName0, 'region' => $agencyOfficeRegion0, 'city' => $agencyOfficeCity0, 'address' => $agencyOfficeAddress0, 'officeNumbers' => User::$agencyOfficeNumbers0, 'phones' => [array('phone' => User::$agencyOfficePhoneNumber0_0), array('phone' => User::$agencyOfficePhoneNumber0_1)]), array('officeName' => User::$agencyOfficeName1, 'region' => $agencyOfficeRegion1, 'city' => $agencyOfficeCity1, 'address' => $agencyOfficeAddress1, 'officeNumbers' => User::$agencyOfficeNumbers1)], 'socialAccounts' => [array('facebook' => User::$agencySocialFb, 'vk' => User::$agencySocialVk)], 'schedule' => [array('dayOfWeek' => '1-5', 'startTime' => '09:00', 'endTime' => '18:00'), array('dayOfWeek' => '6', 'startTime' => '10:00', 'endTime' => '13:00')]]);
     $this->restModule->seeResponseCodeIs(201);
     $this->restModule->seeResponseIsJson();
     $agency_data = $this->restModule->grabResponse();
     file_put_contents(codecept_data_dir('agency_data.json'), $agency_data);
 }
예제 #5
0
 /**
  * @Issue https://github.com/Codeception/Codeception/issues/2075
  * Client is undefined for the second test
  */
 public function testTwoTests()
 {
     $cest1 = Stub::makeEmpty('\\Codeception\\TestCase\\Cest');
     $cest2 = Stub::makeEmpty('\\Codeception\\TestCase\\Cest');
     $this->module->sendGET('/rest/user/');
     $this->module->seeResponseIsJson();
     $this->module->seeResponseContains('davert');
     $this->module->seeResponseContainsJson(array('name' => 'davert'));
     $this->module->seeResponseCodeIs(200);
     $this->module->dontSeeResponseCodeIs(404);
     $this->phpBrowser->_after($cest1);
     $this->module->_after($cest1);
     $this->module->_before($cest2);
     $this->phpBrowser->_before($cest2);
     $this->module->sendGET('/rest/user/');
     $this->module->seeResponseIsJson();
     $this->module->seeResponseContains('davert');
     $this->module->seeResponseContainsJson(array('name' => 'davert'));
     $this->module->seeResponseCodeIs(200);
     $this->module->dontSeeResponseCodeIs(404);
 }
예제 #6
0
 public function testCanInspectResultOfPhpBrowserRequest()
 {
     $this->phpBrowser->amOnPage('/rest/user/');
     $this->module->seeResponseCodeIs(200);
     $this->module->seeResponseIsJson();
 }
예제 #7
0
 public function testSeeResponseIsJsonFailsWhenResponseIsInvalidJson()
 {
     $this->shouldFail();
     $this->setStubResponse('{');
     $this->module->seeResponseIsJson();
 }