protected function setUp() {
parent::setUp();
}
-
+
function testLoggingReport() {
// This is the path where our testing install resides.
// The rest of URL is defined in CiviSeleniumTestCase base class, in
$this->open($this->sboxPath . "civicrm/admin/setting/misc?reset=1");
$this->click("xpath=//tr[@class='crm-miscellaneous-form-block-logging']/td[2]/label[text()='Yes']");
$this->click("_qf_Miscellaneous_next-top");
-
$this->waitForTextPresent("Changes Saved");
-
- // Enable CiviCase component
- $this->open($this->sboxPath . "civicrm/admin/setting/component?reset=1");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Component_next-bottom");
+
+ //enable CiviCase component
+ $this->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom');
$enabledComponents = $this->getSelectOptions("enableComponents-t");
if (!in_array("CiviCase", $enabledComponents)) {
$this->addSelection("enableComponents-f", "label=CiviCase");
$this->click("add");
$this->click("_qf_Component_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Changes Saved."));
+ $this->assertElementContainsText('crm-notification-container', "Changes Saved");
}
//add new contact
$orginalFirstName = $firstName = 'Anthony' . substr(sha1(rand()), 0, 7);
$lastName = 'Anderson' . substr(sha1(rand()), 0, 7);
-
+
$this->webtestAddContact($firstName, $lastName);
$cid = explode('&cid=', $this->getLocation());
sleep(3);
$this->select("group_id", "label=Case Resources");
$this->click("_qf_GroupContact_next");
-
+
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForElementPresent("xpath=//div[@id='groupContact']/div/div[4]/table/tbody/tr/td[4]/a");
$this->click("xpath=//div[@id='groupContact']/div/div[4]/table/tbody/tr/td[4]/a");
-
- // Check confirmation alert.
+
+ // Check confirmation alert.
$this->assertTrue((bool)preg_match("/^Are you sure you want to remove/",
$this->getConfirmation()
));
$this->chooseOkOnNextConfirmation();
$this->waitForPageToLoad($this->getTimeoutMsec());
- //tag addition
+ //tag addition
$this->waitForElementPresent("xpath=//li[@id='tab_tag']/a");
$this->click("xpath=//li[@id='tab_tag']/a");
sleep(3);
$this->click("_qf_Note_upload-top");
$this->waitForElementPresent("xpath=//div[@id='notes']//a[text()='Edit']");
$this->click("xpath=//div[@id='notes']//a[text()='Edit']");
-
+
$this->waitForElementPresent("_qf_Note_upload-top");
$this->type('subject', $noteSubject . "_edited");
$this->type('note', $noteText . "_edited");
$this->click("_qf_Note_upload-top");
-
+
$this->waitForElementPresent("xpath=//div[@class='crm-results-block']/div[@id='notes']/div/table/tbody/tr//td/span[2]/ul/li[2]/a[text()='Delete']");
$this->click("xpath=//div[@class='crm-results-block']/div[@id='notes']/div/table/tbody/tr//td/span[2]/ul/li[2]/a[text()='Delete']");
- // Check confirmation alert.
+ // Check confirmation alert.
$this->assertTrue((bool)preg_match("/^Are you sure you want to delete this note/",
$this->getConfirmation()
));
$this->chooseOkOnNextConfirmation();
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
//add new relationship , disable it , delete it
$this->waitForElementPresent("xpath=//li[@id='tab_rel']/a");
$this->click("xpath=//li[@id='tab_rel']/a");
$this->type("first_name", $firstName);
$this->click("_qf_Contact_upload_view-top");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
//add an activity
$this->click("xpath=//li[@id='tab_activity']/a");
$this->waitForElementPresent("other_activity");
$this->select("status_id","value=2");
$this->click('_qf_Activity_upload-bottom');
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
//add a case
$this->click("xpath=//li[@id='tab_case']/a");
$this->waitForElementPresent("xpath=//div[@id='Cases']//div[@class='action-link']/a");
$this->select("case_status_id","value=2");
$this->click("_qf_Activity_upload-top");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
//visit the logging contact summary report
$this->open($this->sboxPath . "civicrm/report/logging/contact/summary?reset=1");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForPageToLoad($this->getTimeoutMsec());
$data = array(
- //contact data check
- array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"),
- array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"),
- //relationship data check
- array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Update"),
- array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Insert"),
- array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Delete"),
- //group data check
- array("log_type" => "Group", "altered_contact" => "{$firstName} {$lastName} [Case Resources]", "action" => "Added"),
- array("log_type" => "Group", "altered_contact" => "{$firstName} {$lastName} [Case Resources]", "action" => "Removed"),
- //note data check
- array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"),
- array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"),
- array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Delete"),
- //tags data check
- array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Insert"),
- array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Government Entity]", "action" => "Insert"),
- array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Delete"),
- //case data check
- array("log_type" => "Case", "altered_contact" => "{$firstName} {$lastName} [Housing Support]", "action" => "Update"),
- array("log_type" => "Case", "altered_contact" => "{$firstName} {$lastName} [Housing Support]", "action" => "Insert"),
- //case activity check
- array("log_type" => "Activity", "altered_contact" => "{$firstName} {$lastName} [Interview]", "action" => "Update"),
- array("log_type" => "Activity", "altered_contact" => "{$firstName} {$lastName} [Interview]", "action" => "Insert"),
- );
+ //contact data check
+ array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"),
+ array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"),
+ //relationship data check
+ array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Update"),
+ array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Insert"),
+ array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Delete"),
+ //group data check
+ array("log_type" => "Group", "altered_contact" => "{$firstName} {$lastName} [Case Resources]", "action" => "Added"),
+ array("log_type" => "Group", "altered_contact" => "{$firstName} {$lastName} [Case Resources]", "action" => "Removed"),
+ //note data check
+ array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"),
+ array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"),
+ array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Delete"),
+ //tags data check
+ array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Insert"),
+ array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Government Entity]", "action" => "Insert"),
+ array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Delete"),
+ //case data check
+ array("log_type" => "Case", "altered_contact" => "{$firstName} {$lastName} [Housing Support]", "action" => "Update"),
+ array("log_type" => "Case", "altered_contact" => "{$firstName} {$lastName} [Housing Support]", "action" => "Insert"),
+ //case activity check
+ array("log_type" => "Activity", "altered_contact" => "{$firstName} {$lastName} [Interview]", "action" => "Update"),
+ array("log_type" => "Activity", "altered_contact" => "{$firstName} {$lastName} [Interview]", "action" => "Insert"),
+ );
$this->verifyReportData($data);
-
+
//update link (logging details report check)
$contactInfo = array();
$contactInfo['data'] = array(
// array('field' => 'Addressee', 'changed_from' => "{$orginalFirstName} {$lastName}", 'changed_to' => "{$firstName} {$lastName}"),
);
$contactInfo = array_merge($contactInfo, $data[0]);
-
+
$relationshipInfo = array();
$relationshipInfo['data'] = array(
- array('field' => 'Relationship Is Active', 'changed_from' => 'true', 'changed_to' => 'false')
+ array('field' => 'Relationship Is Active', 'changed_from' => 'true', 'changed_to' => 'false')
);
$relationshipInfo = array_merge($relationshipInfo, $data[2]);
);
$caseInfo = array_merge($caseInfo, $data[13]);
- $activityInfo = array();
- $activityInfo['data'] = array(
- array('field' => 'Activity Status Id', 'changed_from' => 'Scheduled', 'changed_to' => 'Completed'),
- );
- $activityInfo = array_merge($activityInfo, $data[15]);
+ $activityInfo = array();
+ $activityInfo['data'] = array(
+ array('field' => 'Activity Status Id', 'changed_from' => 'Scheduled', 'changed_to' => 'Completed'),
+ );
+ $activityInfo = array_merge($activityInfo, $data[15]);
$dataForReportDetail = array($contactInfo, $relationshipInfo, $noteInfo, $caseInfo, $activityInfo);
$filters = array(
'text' => array('altered_contact_value' => "{$firstName} {$lastName}"),
);
$this->detailReportCheck($dataForReportDetail, $filters);
-
+
//delete contact check
$this->open($this->sboxPath . "civicrm/contact/view/delete?&reset=1&delete=1&cid={$cid[1]}");
$this->click("_qf_Delete_done");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
$this->open($this->sboxPath . "civicrm/report/logging/contact/summary?reset=1");
$this->click("_qf_LoggingSummary_submit");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
$contactDataDelete = array(array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Delete (to trash)"));
$this->verifyReportData($contactDataDelete);
-
+
//disable the logging
$this->open($this->sboxPath . "civicrm/admin/setting/misc?reset=1");
$this->click("xpath=//tr[@class='crm-miscellaneous-form-block-logging']/td[2]/label[text()='No']");
$this->click("_qf_Miscellaneous_next-top");
$this->waitForTextPresent("Changes Saved");
}
-
+
function verifyReportData($data) {
foreach ($data as $value) {
// check for the row contains proper data
$actionPath = ($value['action'] == 'Update') ? "td[1]/a[2]" : "td[1][contains(text(), '{$value['action']}')]";
$contactCheck = ($value['action'] == 'Delete (to trash)') ? "td[4][contains(text(), '{$value['altered_contact']}')]" : "td[4]/a[contains(text(), '{$value['altered_contact']}')]/..";
-
+
$this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../{$contactCheck}/../{$actionPath}"), "The proper record not present for (log type : {$value['log_type']}, altered contact : {$value['altered_contact']}, action as {$value['action']})");
-
+
if ($value['action'] == 'Update') {
$this->assertTrue( ($value['action'] == $this->getText("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../td[4]/a[contains(text(), '{$value['altered_contact']}')]/../../{$actionPath}")), "The proper record action {$value['action']} not present for (log type : {$value['log_type']}, altered contact : {$value['altered_contact']} record)");
}
}
}
-
+
function detailReportCheck($dataForReportDetail, $filters = array()) {
foreach ($dataForReportDetail as $value) {
$this->waitForElementPresent("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../td[4]/a[contains(text(), '{$value['altered_contact']}')]/../../td[1]/a[2]");
$this->click("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../td[4]/a[contains(text(), '{$value['altered_contact']}')]/../../td[1]/a[2]");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
foreach ($value['data'] as $key => $data) {
$rowCount = $this->getXpathCount("//table[@class='report-layout display']/tbody/tr");
for ($i = 1; $i <= $rowCount; $i++) {
}
}
$this->click("_qf_LoggingSummary_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->waitForPageToLoad($this->getTimeoutMsec());
}
}
}
\ No newline at end of file
$this->type("edit-name", $role1);
$this->click("edit-add");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
$this->open($this->sboxPath . "admin/people/permissions/roles");
$this->waitForElementPresent("edit-add");
$this->type("edit-name", $role2);
$this->_roleDelete($role1);
$this->_roleDelete($role2);
}
-
+
/*
*check for CRM-10148
*/
$this->type("edit-name", $role);
$this->click("edit-add");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
$this->open($this->sboxPath . "admin/people/permissions/roles");
$this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']");
$roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']/../td[4]/a[text()='edit permissions']/@href"));
"edit-{$roleId}-view-all-contacts",
"edit-{$roleId}-administer-reports",
"edit-{$roleId}-access-civicrm"
- );
+ );
$this->changePermissions($permissions);
-
+
$this->open($this->sboxPath . "civicrm/logout?reset=1");
$this->open($this->sboxPath);
$this->waitForElementPresent('edit-submit');
"edit-{$roleId}-administer-reserved-reports"
);
$this->changePermissions($permissions);
-
+
$this->open($this->sboxPath . "civicrm/report/instance/1?reset=1");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->click("is_reserved");
$this->click("_qf_Summary_submit_save");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
$this->open($this->sboxPath . "civicrm/logout?reset=1");
$this->open($this->sboxPath);
$this->waitForElementPresent('edit-submit');
//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->open($this->sboxPath);
$this->webtestLogin(TRUE);
$this->open($this->sboxPath . "admin/people/permissions");
$this->waitForElementPresent("edit-submit");
-
+
if ($this->isChecked("edit-2-administer-reserved-reports")) {
$this->click("edit-2-administer-reserved-reports");
} else {
$this->open($this->sboxPath);
$this->waitForElementPresent('edit-submit');
$this->type('edit-name', $user);
- $this->type('edit-pass', 'Test12345');
+ $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());
-
+
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");
+ $this->verifyNotText("xpath=//form[@id='Summary']/div[2]/div/div/div", "Report Criteria");
}
if ($this->isElementPresent("xpath=//form[@id='Summary']/div[2]/div[2]/div")) {
- $this->verifyNotText("xpath=//form[@id='Summary']/div[2]/div[2]/div", "Report Settings");
+ $this->verifyNotText("xpath=//form[@id='Summary']/div[2]/div[2]/div", "Report Settings");
}
-
+
$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->click("is_reserved");
$this->click("_qf_Summary_submit_save");
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
$this->open($this->sboxPath . "civicrm/logout?reset=1");
$this->open($this->sboxPath);
$this->waitForElementPresent('edit-submit');
$this->type('edit-name', $user);
- $this->type('edit-pass', 'Test12345');
+ $this->type('edit-pass', 'Test12345');
$this->click('edit-submit');
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->open($this->sboxPath . "civicrm/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->open($this->sboxPath);
$this->open($this->sboxPath . "admin/people/permissions/roles");
$this->_roleDelete($role);
}
-
+
function _roleDelete($role) {
$this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[text()='{$role}']/..//td/a[text()='edit role']");
$this->click("xpath=//table[@id='user-roles']/tbody//tr/td[text()='{$role}']/..//td/a[text()='edit role']");
$this->waitForPageToLoad($this->getTimeoutMsec());
return $name;
}
-}
-
-
+}
\ No newline at end of file