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;
 }
 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;
 }
 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());
     }
 }
 /**
  * @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;
 }
 /**
  * @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);
     }
 }
 /**
  * @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());
 }
 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 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());
 }
 /**
  * @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);
 }
 /**
  * Data provider for SOAP API tests
  *
  * @return array
  */
 public function requestsApi()
 {
     return ToolsAPI::requestsApi(__DIR__ . DIRECTORY_SEPARATOR . 'requests');
 }
 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();
     }
 }
 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);
 }
 /**
  * @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);
 }
 /**
  * @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);
 }
 public function setUp()
 {
     $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader());
 }
 /**
  * @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, '');
 }
 /**
  * @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']);
 }
 /**
  * @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 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);
     }
 }