コード例 #1
0
 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);
 }
コード例 #2
0
 public function testGroupAdd()
 {
     $randomPrefix = ToolsAPI::randomGen(5);
     $login = new Login($this);
     $groups = $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN)->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS)->submit()->openGroups()->add()->setName($this->newGroup['NAME'] . $randomPrefix)->setOwner('Main')->save()->assertMessage('Group saved')->close();
     $this->assertTrue($groups->entityExists(array('name' => $this->newGroup['NAME'] . $randomPrefix)));
     return $randomPrefix;
 }
コード例 #3
0
 public function setUp()
 {
     $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader());
     $this->client->soap("http://localhost/api/soap", array('location' => 'http://localhost/api/soap', 'soap_version' => SOAP_1_2));
     if (!self::$hasLoaded) {
         $this->client->appendFixtures(__DIR__ . DIRECTORY_SEPARATOR . 'DataFixtures');
     }
     self::$hasLoaded = true;
 }
コード例 #4
0
 public function testInvalidUser()
 {
     $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader(self::USER_NAME, ToolsAPI::USER_PASSWORD));
     try {
         $this->client->soap("http://localhost/api/soap", array('location' => 'http://localhost/api/soap', 'soap_version' => SOAP_1_2));
     } catch (\Exception $e) {
         $this->assertEquals('Unauthorized', $e->getMessage());
     }
 }
コード例 #5
0
 /**
  * @depends testGetAddressTypes
  * @param array $expected
  */
 public function testGetAddressType($expected)
 {
     foreach ($expected as $addrType) {
         $result = $this->client->getSoap()->getAddressType($addrType['name']);
         $result = ToolsAPI::classToArray($result);
         $this->assertNotEmpty($result);
         $this->assertEquals($addrType, $result);
     }
 }
コード例 #6
0
 /**
  * Test POST
  * @return string
  */
 public function testCreate()
 {
     $this->markTestSkipped('BAP-1375');
     $result = $this->client->getSoap()->createBusinessUnit($this->fixtureData['business_unit']);
     $responseData = ToolsAPI::classToArray($result);
     $this->assertNotEmpty($responseData);
     $this->assertInternalType('array', $responseData);
     $this->assertArrayHasKey('id', $responseData);
     return $responseData['id'];
 }
コード例 #7
0
 public function testRolesAdd()
 {
     $randomPrefix = ToolsAPI::randomGen(5);
     $login = new Login($this);
     $roles = $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN)->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS)->submit()->openRoles()->add()->setLabel($this->newRole['LABEL'] . $randomPrefix)->setOwner('Main')->save()->assertMessage('Role saved')->close();
     //verify new Role
     $roles->refresh();
     $this->assertTrue($roles->entityExists(array('name' => $this->newRole['LABEL'] . $randomPrefix)));
     return $randomPrefix;
 }
コード例 #8
0
 /**
  * @param  array $response
  * @return array
  * @depends testGetAudits
  */
 public function testGetAudit($response)
 {
     foreach ($response as $audit) {
         $result = $this->client->getSoap()->getAudit($audit['id']);
         $result = ToolsAPI::classToArray($result);
         unset($result['loggedAt']);
         unset($audit['loggedAt']);
         $this->assertEquals($audit, $result);
     }
 }
コード例 #9
0
 /**
  * @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());
 }
コード例 #10
0
 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());
 }
コード例 #11
0
 /**
  * @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);
     }
 }
コード例 #12
0
 /**
  * @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);
     }
 }
コード例 #13
0
 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());
 }
コード例 #14
0
 /**
  * @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']);
 }
コード例 #15
0
 /**
  * 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);
 }
コード例 #16
0
 /**
  * Data provider for SOAP API tests
  *
  * @return array
  */
 public function requestsApi()
 {
     return ToolsAPI::requestsApi(__DIR__ . DIRECTORY_SEPARATOR . 'requests');
 }
コード例 #17
0
 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());
 }
コード例 #18
0
 /**
  * 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();
     }
 }
コード例 #19
0
 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);
 }
コード例 #20
0
 /**
  * @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);
 }
コード例 #21
0
 /**
  * @depends testRemoveAclsFromRole
  */
 public function testAddAclsToRole($expectedAcl)
 {
     $roleId = $this->client->getSoap()->getRoleByName(self::TEST_EDIT_ROLE);
     $roleId = ToolsAPI::classToArray($roleId);
     $this->client->getSoap()->addAclsToRole($roleId['id'], array('oro_security', 'oro_address'));
     $result = $this->client->getSoap()->getRoleAcl($roleId['id']);
     $result = ToolsAPI::classToArray($result);
     $actualAcl = $result['item'];
     sort($actualAcl);
     $this->assertEquals($expectedAcl, $actualAcl);
 }
コード例 #22
0
 public function setUp()
 {
     $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader());
 }
コード例 #23
0
 /**
  * @Given /^I press "([^"]*)"$/
  */
 public function iPress($button)
 {
     $client = $this->getInstance();
     $client->followRedirects();
     $client->submit($this->form);
     \Oro\Bundle\TestFrameworkBundle\Test\ToolsAPI::assertJsonResponse($client->getResponse(), 200, '');
 }
コード例 #24
0
 /**
  * @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']);
 }
コード例 #25
0
 /**
  * @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);
 }
コード例 #26
0
 /**
  * @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);
 }
コード例 #27
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);
     }
 }
コード例 #28
0
 /**
  * @depends testGetRegion
  */
 public function testGetCountryRegion()
 {
     $result = $this->client->getSoap()->getRegionByCountry('US');
     $result = ToolsAPI::classToArray($result);
     foreach ($result['item'] as $region) {
         $region['country'] = $region['country']['name'];
         $expectedResult = $this->client->getSoap()->getRegion($region['combinedCode']);
         $expectedResult = ToolsAPI::classToArray($expectedResult);
         $this->assertEquals($expectedResult, $region);
     }
 }