public function testInvalidUser() { $request = array("user" => array("username" => 'user_' . mt_rand(), "email" => 'test_' . mt_rand() . '@test.com', "enabled" => 'true', "plainPassword" => '1231231q', "firstName" => "firstName", "lastName" => "lastName", "rolesCollection" => array("1"))); $this->client->request('POST', $this->client->generate('oro_api_post_user'), $request, array(), array(), ToolsAPI::generateWsseHeader(self::USER_NAME, ToolsAPI::USER_PASSWORD)); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 401); }
/** * @depends testApiGetRoleById * @param $roleId */ public function testApiDeleteRole($roleId) { $this->client->request('DELETE', $this->client->generate('oro_api_delete_role', array('id' => $roleId))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); $this->client->request('GET', $this->client->generate('oro_api_get_role', array('id' => $roleId))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 404); }
/** * @depends testApiUpdateUser * @param int $userId */ public function testApiDeleteUser($userId) { $this->client->request('DELETE', $this->client->generate('oro_api_delete_user', array('id' => $userId))); $result = $this->client->getResponse(); $this->assertJsonResponse($result, 204); $this->client->request('GET', $this->client->generate('oro_api_get_user', array('id' => $userId))); $result = $this->client->getResponse(); $this->assertJsonResponse($result, 404); }
/** * @depends testRunDaemon */ public function testStopDaemon() { $this->client->request('GET', $this->client->generate('oro_cron_job_stop_daemon')); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200, 'text/html; charset=UTF-8'); $this->client->request('GET', $this->client->generate('oro_cron_job_status'), array(), array(), array('HTTP_X-Requested-With' => 'XMLHttpRequest')); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200, 'text/html; charset=UTF-8'); $this->assertEquals(0, (int) $result->getContent()); }
/** * @param array $request * @param array $response * * @dataProvider requestsApi */ public function testApi($request, $response) { $requestUrl = $request['query']; $this->client->request('GET', $this->client->generate('oro_api_get_search_advanced'), array('query' => $requestUrl)); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); $result = json_decode($result->getContent(), true); //compare result $this->assertEqualsResponse($response, $result); }
public function testSearch() { $result = ToolsAPI::getEntityGrid($this->client, 'tag-grid', array('tag-grid[_filter][name][value]' => 'tag758_updated')); ToolsAPI::assertJsonResponse($result, 200); $result = ToolsAPI::jsonToArray($result->getContent()); $result = reset($result['data']); $this->client->request('GET', $this->client->generate('oro_tag_search', array('id' => $result['id']))); $result = $this->client->getResponse(); $this->assertContains('Records tagged as "tag758_updated"', $result->getContent()); $this->assertContains('No results were found', $result->getContent()); }
/** * @param array $response * @depends testGetAudits */ public function testGetAudit($response) { foreach ($response as $audit) { $this->client->request('GET', $this->client->generate('oro_api_get_audit', array('id' => $audit['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); $result = ToolsAPI::jsonToArray($result->getContent()); unset($result['loggedAt']); unset($audit['loggedAt']); $this->assertEquals($audit, $result); } }
/** * @depends testGetAddressTypes * @param array $expected */ public function testGetAddressType($expected) { foreach ($expected as $addrType) { $this->client->request('GET', $this->client->generate('oro_api_get_addresstype', array('name' => $addrType['name']))); /** @var $result Response */ $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); $result = ToolsAPI::jsonToArray($result->getContent()); $this->assertNotEmpty($result); $this->assertEquals($addrType, $result); } }
/** * @depends testUpdate * @param string $id */ public function testView($id) { $crawler = $this->client->request('GET', $this->client->generate('oro_business_unit_view', array('id' => $id))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200, 'text/html; charset=UTF-8'); $this->assertContains("testBU_Updated - Business Units - Users Management - System", $crawler->html()); }
public function testSubmit() { $form = $this->chooseEmbeddedFormFromGrid(); $formViewUrl = $this->getUrl('diamante_embedded_form_submit', array('id' => $form['id'])); $crawler = $this->client->request('GET', $formViewUrl); /** @var Form $form */ $form = $crawler->selectButton('Submit')->form(); $form['diamante_embedded_form[firstName]'] = 'John'; $form['diamante_embedded_form[lastName]'] = 'Smith'; $form['diamante_embedded_form[emailAddress]'] = '*****@*****.**'; $form['diamante_embedded_form[subject]'] = 'Subject of ticket'; $form['diamante_embedded_form[description]'] = 'Write something about problem'; $this->client->followRedirects(true); $crawler = $this->client->submit($form); $response = $this->client->getResponse(); $this->assertEquals(200, $response->getStatusCode()); $this->assertContains("Ticket has been placed successfully", $crawler->html()); }
/** * @depends testApiUpdateGroup * @param $group */ public function apiDeleteGroup($group) { $this->client->request('DELETE', $this->client->generate('oro_api_delete_group', array('id' => $group['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); $this->client->request('GET', $this->client->generate('oro_api_get_group', array('id' => $group['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 404); }
/** * @depends testCreate */ public function testDelete() { $result = ToolsAPI::getEntityGrid($this->client, 'email-notification-grid', array('email-notification-grid[_pager][_page]' => 1, 'email-notification-grid[_pager][_per_page]' => 1)); ToolsAPI::assertJsonResponse($result, 200); $result = ToolsAPI::jsonToArray($result->getContent()); $result = reset($result['data']); $this->client->request('DELETE', $this->client->generate('oro_api_delete_emailnotication', array('id' => $result['id']))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); }
/** * @param string $method * @param string $url * @param int $code * @param array $urlParameters * @param array $requestParameters * @param string $assert * * @return \Symfony\Component\HttpFoundation\Response */ protected function request($method, $url, $code, $urlParameters = array(), $requestParameters = array(), $assert = 'assertJsonResponseStatusCodeEquals') { $server = $this->generateWsse(); $this->client->setServerParameters($server); $this->client->insulate(); $this->client->request($method, $this->getUrl($url, $urlParameters), $requestParameters); $result = $this->client->getResponse(); $this->{$assert}($result, $code); return $result; }
/** * Test DELETE * * @depends testCreate * @param string $id */ public function testDelete($id) { $this->client->request('DELETE', $this->client->generate('oro_api_delete_businessunit', array('id' => $id))); /** @var $result Response */ $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 204); $this->client->request('GET', $this->client->generate('oro_api_get_businessunit', array('id' => $id))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 404); }
public function testCreate() { $this->markTestIncomplete('Skipped due to issue with dynamic form loading'); $crawler = $this->client->request('GET', $this->client->generate('oro_email_emailtemplate_create')); $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->loadHTML($crawler->html()); $dom->getElementById('oro_email_emailtemplate'); $form = $crawler->filterXPath("//form[@name='oro_email_emailtemplate']"); $form = $crawler->selectButton('Save and Close')->form(); $fields = $form->all(); $form['oro_email_emailtemplate[entityName]'] = 'Oro\\Bundle\\UserBundle\\Entity\\User'; $form['oro_email_emailtemplate[name]'] = 'User Template'; $form['oro_email_emailtemplate[translations][defaultLocale][en][content]'] = 'Content template'; $form['oro_email_emailtemplate[translations][defaultLocale][en][subject]'] = 'Subject'; $form['oro_email_emailtemplate[type]'] = 'html'; $this->client->followRedirects(true); $crawler = $this->client->submit($form); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200, ''); $this->assertContains("Template saved", $crawler->html()); }
/** * Test Empty Body error * * @depends testNotFound * @dataProvider navagationItemsProvider */ public function testEmptyBody($itemType) { $this->assertNotEmpty(self::$entities[$itemType]); $requests = array('POST' => $this->client->generate('oro_api_post_navigationitems', array('type' => $itemType)), 'PUT' => $this->client->generate('oro_api_put_navigationitems_id', array('type' => $itemType, 'itemId' => self::$entities[$itemType]['id']))); foreach ($requests as $requestType => $url) { $this->client->request($requestType, $url, array(), array(), ToolsAPI::generateWsseHeader()); /** @var $response Response */ $response = $this->client->getResponse(); ToolsAPI::assertJsonResponse($response, 400); $responseJson = json_decode($response->getContent(), true); $this->assertArrayHasKey('message', $responseJson); $this->assertEquals('Wrong JSON inside POST body', $responseJson['message']); $this->client->restart(); } }
public function testGetCountryRegion() { $this->client->request('GET', $this->client->generate('oro_api_country_get_regions', array('country' => 'US'))); /** @var $result Response */ $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200); $result = ToolsAPI::jsonToArray($result->getContent()); foreach ($result as $region) { $this->client->request('GET', $this->client->generate('oro_api_get_region'), array('id' => $region['combined_code'])); /** @var $result Response */ $expectedResult = $this->client->getResponse(); ToolsAPI::assertJsonResponse($expectedResult, 200); $expectedResult = ToolsAPI::jsonToArray($expectedResult->getContent()); $this->assertEquals($expectedResult, $region); } }
public function testUpdateProfile() { $crawler = $this->client->request('GET', $this->client->generate('oro_user_profile_update')); ToolsAPI::assertJsonResponse($this->client->getResponse(), 200, 'text/html; charset=UTF-8'); $this->assertContains('John Doe - Edit - Users - Users Management - System', $this->client->getResponse()->getContent()); /** @var Form $form */ $form = $crawler->selectButton('Save and Close')->form(); $form['oro_user_user_form[birthday]'] = '1999-01-01'; $this->client->followRedirects(true); $crawler = $this->client->submit($form); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200, 'text/html; charset=UTF-8'); $this->assertContains("User saved", $crawler->html()); $crawler = $this->client->request('GET', $this->client->generate('oro_user_profile_update')); ToolsAPI::assertJsonResponse($this->client->getResponse(), 200, 'text/html; charset=UTF-8'); $this->assertContains('John Doe - Edit - Users - Users Management - System', $this->client->getResponse()->getContent()); /** @var Form $form */ $form = $crawler->selectButton('Save and Close')->form(); $this->assertEquals('1999-01-01', $form['oro_user_user_form[birthday]']->getValue()); }
public function testApiDeleteUser() { $this->client->request('DELETE', $this->client->generate('oro_api_delete_user', array('id' => self::DEFAULT_USER_ID))); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 403); }
/** * @param Client $test * @param $gridParameters * @param array $filter * @return \Symfony\Component\HttpFoundation\Response */ public static function getEntityGrid($test, $gridParameters, $filter = array()) { if (is_string($gridParameters)) { $gridParameters = array('gridName' => $gridParameters); } //transform parameters to nested array $parameters = array(); foreach ($filter as $param => $value) { $param .= '=' . $value; parse_str($param, $output); $parameters = array_merge_recursive($parameters, $output); } $gridParameters = array_merge_recursive($gridParameters, $parameters); $test->request('GET', $test->generate('oro_datagrid_index', $gridParameters)); return $test->getResponse(); }
public function testIndex() { $this->client->request('GET', $this->client->generate('oro_dataaudit_index')); $result = $this->client->getResponse(); ToolsAPI::assertJsonResponse($result, 200, 'text/html; charset=UTF-8'); }