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());
 }
 /**
  * @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);
     }
 }
 /**
  * @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);
     }
 }
 public function testApiGen()
 {
     $result = ToolsAPI::getEntityGrid($this->client, 'users-grid', array('users-grid[_filter][username][value]' => 'testUser1'));
     ToolsAPI::assertJsonResponse($result, 200);
     $result = ToolsAPI::jsonToArray($result->getContent());
     $result = reset($result['data']);
     $this->client->request('GET', $this->client->generate('oro_user_apigen', array('id' => $result['id'])), array(), array(), array('HTTP_X-Requested-With' => 'XMLHttpRequest'));
     /** @var User $user */
     $user = $this->client->getContainer()->get('doctrine')->getRepository('OroUserBundle:User')->findOneBy(array('id' => $result['id']));
     $result = $this->client->getResponse();
     ToolsAPI::assertJsonResponse($result, 200, '');
     //verify result
     $this->assertEquals($user->getApi()->getApiKey(), trim($result->getContent(), '"'));
 }
 /**
  * @depends testAudit
  * @param $result
  */
 public function testAuditHistory($result)
 {
     $result = ToolsAPI::getEntityGrid($this->client, 'audit-history-grid', array('audit-history-grid[object_class]' => str_replace('\\', '_', $result['objectClass']), 'audit-history-grid[object_id]' => $result['objectId']));
     ToolsAPI::assertJsonResponse($result, 200);
     $result = ToolsAPI::jsonToArray($result->getContent());
     $result = reset($result['data']);
     $result['old'] = $this->clearResult($result['old']);
     $result['new'] = $this->clearResult($result['new']);
     foreach ($result['old'] as $auditRecord) {
         $auditValue = explode(': ', $auditRecord, 2);
         $this->assertEmpty(trim($auditValue[1]));
     }
     foreach ($result['new'] as $auditRecord) {
         $auditValue = explode(': ', $auditRecord, 2);
         $key = trim($auditValue[0]);
         $value = trim($auditValue[1]);
         if ($key == 'birthday') {
             $value = $this->getFormattedDate($value);
         }
         $this->assertEquals($this->userData[$key], $value);
     }
     $this->assertEquals('John Doe  - admin@example.com', $result['author']);
 }
Exemplo n.º 6
0
 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);
     }
 }
 /**
  * @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);
 }
Exemplo n.º 8
0
 /**
  * Test PUT
  *
  * @depends testCreate
  * @param string $id
  */
 public function testUpdate($id)
 {
     $requestData = $this->fixtureData;
     $requestData['business_unit']['name'] = $requestData['business_unit']['name'] . '_updated';
     $this->client->request('PUT', $this->client->generate('oro_api_put_businessunit', array('id' => $id)), $requestData);
     $result = $this->client->getResponse();
     ToolsAPI::assertJsonResponse($result, 204);
     // open address by id
     $this->client->request('GET', $this->client->generate('oro_api_get_businessunit', array('id' => $id)));
     $result = $this->client->getResponse();
     ToolsAPI::assertJsonResponse($result, 200);
     $result = ToolsAPI::jsonToArray($result->getContent());
     $this->assertEquals($requestData['business_unit']['name'], $result['name']);
 }
 /**
  * @depends testUpdate
  * @depends testCreate
  * @param string $id
  * @param array $user
  */
 public function testViewUsers($id, $user)
 {
     $result = ToolsAPI::getEntityGrid($this->client, 'bu-view-users-grid', array('bu-view-users-grid[business_unit_id]' => $id));
     ToolsAPI::assertJsonResponse($result, 200);
     $result = ToolsAPI::jsonToArray($result->getContent());
     $result = reset($result['data']);
     $this->assertEquals($user['request']['user']['username'], $result['username']);
 }