public function testFileUploadWithFilesArray() { $tmpFileName = tempnam('/tmp', 'test_'); file_put_contents($tmpFileName, 'test data'); $files = ['file' => ['name' => 'file.txt', 'type' => 'text/plain', 'size' => 9, 'tmp_name' => $tmpFileName]]; $this->module->sendPOST('/rest/file-upload', [], $files); $this->module->seeResponseContainsJson(['uploaded' => true]); }
public function testApplicationJsonSubtypeIncludesObjectSerialized() { $this->module->haveHttpHeader('Content-Type', 'application/resource+json'); $this->module->sendPOST('/', new JsonSerializedItem()); /** @var $request \Symfony\Component\BrowserKit\Request **/ $request = $this->module->client->getRequest(); $this->assertContains('application/resource+json', $request->getServer()); $this->assertJson($request->getContent()); }
public function testApplicationJsonIncludesJsonAsContent() { $this->module->haveHttpHeader('Content-Type', 'application/json'); $this->module->sendPOST('/', array('name' => 'john')); /** @var $request \Symfony\Component\BrowserKit\Request **/ $request = $this->module->client->getRequest(); $this->assertContains('application/json', $request->getServer()); $server = $request->getServer(); $this->assertEquals('application/json', $server['HTTP_CONTENT_TYPE']); $this->assertJson($request->getContent()); $this->assertEmpty($request->getParameters()); }
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); }
public function testPost() { $this->module->sendPOST('/rest/user/', array('name' => 'john')); $this->module->seeResponseContains('john'); $this->module->seeResponseContainsJson(array('name' => 'john')); }