3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Report_AddTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testAddReport() {
35 $this->webtestLogin();
38 $firstName = 'reportuser_' . substr(sha1(rand()), 0, 7);
39 $displayName = "Anderson, $firstName";
40 $emailId = "$firstName.anderson@example.org";
41 $this->webtestAddContact($firstName, "Anderson", $emailId);
43 $this->openCiviPage('report/contact/summary', 'reset=1', '_qf_Summary_submit' );
46 $this->click("fields[email]");
49 $this->click("fields[phone]");
51 // apply Contact Name filter
52 $this->select("sort_name_op", "value=has");
53 $this->type("sort_name_value", $firstName);
56 $this->click("_qf_Summary_submit");
57 $this->waitForPageToLoad($this->getTimeoutMsec());
59 // Is filter statistics present?
60 $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
62 // Is Contact Name present in result?
63 $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
65 // Is email Id present on result?
66 $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
69 $this->click("css=div.crm-report_criteria-accordion div.crm-accordion-header");
70 $this->waitForElementPresent("sort_name_value");
72 // Is Contact Name filter?
73 $this->assertContains($firstName, $this->getValue("sort_name_value"), "Filter Contact Name expected $firstName");
76 $this->assertEquals("on", $this->getValue("fields[email]"));
79 $this->assertEquals("on", $this->getValue("fields[phone]"));
82 $this->click("css=div.crm-report_setting-accordion div.crm-accordion-header");
83 $this->waitForElementPresent("title");
85 $reportName = 'ContactSummary_' . substr(sha1(rand()), 0, 7);
86 $reportDescription = "New Contact Summary Report";
87 $emaiSubject = "Contact Summary Report";
88 $emailCC = "tesmail@example.org";
91 $this->type("title", $reportName);
93 // Fill Report Description
94 $this->type("description", $reportDescription);
97 $this->type("email_subject", $emaiSubject);
100 $this->type("email_to", $emailId);
103 $this->type("email_cc", $emailCC);
105 // We want navigation menu
106 $this->click("is_navigation");
107 $this->waitForElementPresent("parent_id");
109 // Navigation menu under Reports section
110 $this->select("parent_id", "label=Reports");
112 // Set permission as access CiviCRM
113 $this->select("permission", "value=access CiviCRM");
115 // click to create report
116 $this->click("_qf_Summary_submit_save");
117 $this->waitForPageToLoad($this->getTimeoutMsec());
120 $this->openCiviPage('report/list', 'reset=1');
122 // Is report is resent in list?
123 $this->assertElementContainsText('css=table.report-layout', $reportName);
126 $this->click("link=$reportName");
127 $this->waitForPageToLoad($this->getTimeoutMsec());
129 // Is filter statistics present?
130 $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
132 // Is Contact Name present in result?
133 $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
135 // Is email Id present on result?
136 $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
138 // check report criteria
139 $this->click("css=div.crm-report_criteria-accordion div.crm-accordion-header");
140 $this->waitForElementPresent("sort_name_value");
142 // Is Contact Name filter?
143 $this->assertContains($firstName, $this->getValue("sort_name_value"), "Filter Contact Name expected $firstName");
146 $this->assertEquals("on", $this->getValue("fields[email]"));
149 $this->assertEquals("on", $this->getValue("fields[phone]"));
151 // Check Report settings
152 $this->click("css=div.crm-report_setting-accordion div.crm-accordion-header");
153 $this->waitForElementPresent("title");
155 // Is correct Report Title?
156 $this->assertContains($reportName, $this->getValue("title"), "Report Title expected $reportName");
158 // Is correct Report Description?
159 $this->assertContains($reportDescription, $this->getValue("description"), "Report Description expected $reportDescription");
161 // Is correct email Subject?
162 $this->assertContains($emaiSubject, $this->getValue("email_subject"), "Email Subject expected $emaiSubject");
164 // Is correct email to?
165 $this->assertContains($emailId, $this->getValue("email_to"), "Email To expected $emailId");
167 // Is correct email cc?
168 $this->assertContains($emailCC, $this->getValue("email_cc"), "Email CC expected $emailCC");
171 $this->assertEquals("on", $this->getValue("is_navigation"));
173 // Is correct Navigation Parent?
174 $this->assertSelectedLabel("parent_id", "Reports");
176 // Is correct access permission?
177 $this->assertSelectedLabel("permission", "access CiviCRM");