Esempio n. 1
0
 /**
  * Checks whether postRole() actually updates the previously created Role on the server.
  */
 public function testPostRole_updatesRole()
 {
     $this->jc->putRole($this->newRole);
     $old_role_name = $this->newRole->getRoleName();
     $this->newRole->setRoleName('ROLE_TESTER');
     $this->jc->postRole($this->newRole, $old_role_name);
     $tempRole = $this->jc->getRoles($this->newRole->getRoleName(), 'organization_1');
     $this->assertEquals($this->newRole->getRoleName(), $tempRole->getRoleName());
 }
Esempio n. 2
0
 /**
  * Checks getJobs() returns empty array when no jobs are set.
  */
 public function testGetJobs_returnsEmptyWithNoJobs()
 {
     $folder = JasperTestUtils::createFolder();
     $this->jc->putResource('', $folder);
     $jobs = $this->jc->getJobs();
     // Cleanup
     $this->jc->deleteResource($folder->getUriString());
     $this->assertEquals(0, count($jobs));
 }
 /**
  * Does a non-strict sanity check on ReportOptions service.
  */
 public function testCreateOptions_CreatesNewOptions()
 {
     $timecode = substr(md5(microtime()), 0, 5);
     $label = 'test' . $timecode;
     $controlOptions = array('Country_multi_select' => array('USA'));
     $this->jc->updateReportOptions($this->report_uri, $controlOptions, $label, 'true');
     $options = $this->jc->getReportOptions($this->report_uri);
     foreach ($options as $o) {
         if ($o->getLabel() == $label) {
             $this->testSuccess = true;
         }
     }
     $this->jc->deleteReportOptions($this->report_uri, $label);
     $this->assertTrue($this->testSuccess);
 }
 /**
  * Checks if user's attributes are saved correctly when postAttributes() is called with an array of Attributes, that is
  * multiple Attributes.
  */
 public function testPostAttributes_addsMultipleAttributesCount()
 {
     $this->jc->putUsers($this->newUser);
     $attrCount = count($this->jc->getAttributes($this->newUser));
     $this->jc->postAttributes($this->newUser, $this->attrArr);
     $attr2Value = $this->jc->getAttributes($this->newUser);
     $newCount = count($attr2Value);
     $this->jc->deleteUser($this->newUser);
     $this->assertEquals($attrCount + 2, $newCount);
     $this->assertEquals('Anchor Steam', $attr2Value[1]->getAttrValue());
 }
Esempio n. 5
0
 /**
  * Checks delRole() by actually deleting a Role from User.
  */
 public function testRevokingARole_actuallyRevokesARole()
 {
     $user = JasperTestUtils::createUser();
     $role = new Role('ROLE_DEMO', null, 'false');
     $user->addRole($role);
     $this->jc->putUsers($user);
     $createdUser = $this->jc->getUsers($user->getUsername());
     $createdUser = $createdUser[0];
     $this->assertEquals(count($user->getRoles()), count($createdUser->getRoles()));
     $user->delRole($role);
     $this->jc->postUser($user);
     $updatedUser = $this->jc->getUsers($user->getUsername());
     $updatedUser = $updatedUser[0];
     $this->jc->deleteUser($user);
     $this->assertEquals(count($user->getRoles()), count($updatedUser->getRoles()));
     $this->assertEquals(count($createdUser->getRoles()) - 1, count($updatedUser->getRoles()));
 }
 /**
  * Checks updatePermissions() - verifies that this method actually sets Permissions for a resource
  * different than folder (in this case, an image).
  */
 public function testPostPermissionsToResource_addsPermissionCorrectly()
 {
     $this->jc->putResource('/', $this->test_folder);
     $resource = JasperTestUtils::createImage($this->test_folder);
     $this->jc->putResource('', $resource, dirname(__FILE__) . '/resources/pitbull.jpg');
     $resource = $this->jc->getResource($resource->getUriString());
     $joeuser = $this->jc->getUsers('joeuser');
     $perms = $this->jc->getPermissions($resource->getUriString());
     $perm = new Permission('32', $joeuser[0], $resource->getUriString());
     $perms[] = $perm;
     $this->jc->updatePermissions($resource->getUriString(), $perms);
     $updated_perms = $this->jc->getPermissions($resource->getUriString());
     $this->jc->deleteResource($this->test_folder->getUriString());
     $this->assertEquals(sizeof($perms), sizeof($updated_perms));
     $this->assertEquals($perm->getPermissionMask(), $updated_perms[count($updated_perms) - 1]->getPermissionMask());
     $this->assertEquals($perm->getPermissionRecipient(), $updated_perms[count($updated_perms) - 1]->getPermissionRecipient());
 }
Esempio n. 7
0
 /**
  * Checks running a report with custom options when this report has input controls of various types.
  */
 public function testRunSalesByMonthReport()
 {
     $options = array("TextInput" => array("1234"), "CheckboxInput" => array("false"), "ListInput" => array("3"), "DateInput" => array("2012-09-08"), "QueryInput" => array("sally"));
     $report = $this->jc->runReport('/reports/samples/SalesByMonth', 'csv', null, $options);
     $this->assertRegExp("/Number\\,*[0-9\\s]*[\\,\\s]*List\\ item\\,*([0-9]+\\s*)*[\\,\\s]*Date\\,*([0-9]{1,2}\\s+\\w*\\s+[0-9]{4})[\\,\\s]*Query\\ item\\,*sally/u", $report);
     $this->jc->updateReportOptions('/reports/samples/SalesByMonth', $options, 'SalesByMonthTestOptions', 'true');
     $savedOptions = $this->jc->getReportInputControls('/reports/samples/SalesByMonthTestOptions');
     try {
         $this->jc->deleteReportOptions('/reports/samples/SalesByMonth', 'SalesByMonthTestOptions');
     } catch (Exception $e) {
         $this->jc->deleteResource('/reports/samples/SalesByMonthTestOptions');
     }
     $this->assertEquals(1234, (int) $savedOptions[0]->value);
     $this->assertEquals("false", $savedOptions[1]->value);
     $this->assertEquals("false", $savedOptions[2]->options[0]["selected"]);
     $this->assertEquals("false", $savedOptions[2]->options[1]["selected"]);
     $this->assertEquals("true", $savedOptions[2]->options[2]["selected"]);
     $this->assertEquals("2012-09-08", $savedOptions[3]->value);
     $this->assertEquals("true", $savedOptions[4]->options[6]["selected"]);
 }
 /**
  * Checks getRepository() with recursive parameter on - verifies whether reportUnit Resources are found and
  * returned from child folders too (by a plausible number of those).
  */
 public function testGetRepository_recursive()
 {
     $repoSimple = $this->jc->getRepository('/reports', null, 'reportUnit', true);
     $this->assertGreaterThan(15, count($repoSimple));
 }