-- webtest fixes and improvement
[civicrm-core.git] / tests / phpunit / WebTest / Report / RolePermissionReportTest.php
index 8d4e09bd546199e0839edf13ef07f5f28c0a9e78..17b36d3d711d28ea33fc92319e7f5680e4987768 100644 (file)
@@ -84,8 +84,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
     $this->changePermissions($permissions);
 
     // change report setting to for a particular role
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
     $this->click("css=div.crm-report_setting-accordion div.crm-accordion-header");
     $this->waitForElementPresent("_qf_Summary_submit_save");
     $this->select("permission", "value=access CiviCRM");
@@ -93,20 +92,17 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
     $this->click("add");
     $this->click("_qf_Summary_submit_save");
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->waitForElementPresent('edit-submit');
     $this->type('edit-name', $user2);
     $this->type('edit-pass', 'Test12345');
     $this->click('edit-submit');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent("You do not have permission to access this report."));
-    $this->open($this->sboxPath . "civicrm/report/list?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
+    $this->assertElementContainsText('crm-container', 'You do not have permission to access this report.');
+    $this->openCiviPage('report/list', 'reset=1');
+    $this->openCiviPage('logout', 'reset=1', NULL);
 
     //delete roles
     $this->webtestLogin(TRUE);
@@ -145,8 +141,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
     $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']/../td[4]/a[text()='edit permissions']/@href"));
     $roleId = end($roleId);
     $user = $this->_testCreateUser($roleId);
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
     if ($this->isChecked("is_reserved")) {
       $this->click("is_reserved");
       $this->click("_qf_Summary_submit_save");
@@ -160,20 +155,19 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
     );
     $this->changePermissions($permissions);
 
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->waitForElementPresent('edit-submit');
     $this->type('edit-name', $user);
     $this->type('edit-pass', 'Test12345');
     $this->click('edit-submit');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
 
     //check if the reserved report field is frozen
     $this->assertTrue($this->isElementPresent("xpath=//div[@id='instanceForm']//table[3]/tbody//tr/td[2]/tt[text()='[ ]']"));
 
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->webtestLogin(TRUE);
     // let's give full CiviReport permissions.
@@ -186,30 +180,28 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
     );
     $this->changePermissions($permissions);
 
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
 
     //make the report reserved
     $this->click("is_reserved");
     $this->click("_qf_Summary_submit_save");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->waitForElementPresent('edit-submit');
     $this->type('edit-name', $user);
     $this->type('edit-pass', 'Test12345');
     $this->click('edit-submit');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
 
     //check if the report criteria and settings is accessible
     $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='id_default']//input[@id='fields_email']"));
     $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']/table//input[@id='title']"));
 
     //login as admin and remove reserved permission
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->webtestLogin(TRUE);
     $this->open($this->sboxPath . "admin/people/permissions");
@@ -224,15 +216,14 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //login as user and check for absence of report criteria and settings
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->waitForElementPresent('edit-submit');
     $this->type('edit-name', $user);
     $this->type('edit-pass', 'Test12345');
     $this->click('edit-submit');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
 
     if ($this->isElementPresent("xpath=//form[@id='Summary']/div[2]/div/div/div")) {
       $this->verifyNotText("xpath=//form[@id='Summary']/div[2]/div/div/div", "Report Criteria");
@@ -244,30 +235,28 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
     $this->assertFalse($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']//input[@id='title']"));
 
     //login as admin and turn the is_reserved flag off for the instance
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->webtestLogin(TRUE);
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
     $this->click("is_reserved");
     $this->click("_qf_Summary_submit_save");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->waitForElementPresent('edit-submit');
     $this->type('edit-name', $user);
     $this->type('edit-pass', 'Test12345');
     $this->click('edit-submit');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/instance/1', 'reset=1');
 
     $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='id_default']//input[@id='fields_email']"));
     $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']//input[@id='title']"));
 
     //login as admin and delete the role
-    $this->open($this->sboxPath . "civicrm/logout?reset=1");
+    $this->openCiviPage('logout', 'reset=1', NULL);
     $this->open($this->sboxPath);
     $this->webtestLogin(TRUE);
     $this->open($this->sboxPath . "admin/people/permissions/roles");