version fixes
[civicrm-core.git] / tests / phpunit / WebTest / Report / AddTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
25 */
26
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Report_AddTest
31 */
32 class WebTest_Report_AddTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testAddReport() {
39 $this->webtestLogin();
40
41 // create contact
42 $firstName = 'reportuser_' . substr(sha1(rand()), 0, 7);
43 $displayName = "Anderson, $firstName";
44 $emailId = "$firstName.anderson@example.org";
45 $this->webtestAddContact($firstName, "Anderson", $emailId);
46
47 $this->openCiviPage('report/contact/summary', 'reset=1', '_qf_Summary_submit');
48
49 // enable email field
50 $this->click("fields[email]");
51
52 // enable phone field
53 $this->click("fields[phone]");
54
55 // apply Contact Name filter
56 $this->select("sort_name_op", "value=has");
57 $this->type("sort_name_value", $firstName);
58
59 // preview result
60 $this->click("_qf_Summary_submit");
61 $this->waitForPageToLoad($this->getTimeoutMsec());
62
63 // Is filter statistics present?
64 $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
65
66 // Is Contact Name present in result?
67 $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
68
69 // Is email Id present on result?
70 $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
71
72 // check criteria
73 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[3]/a");
74 $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']");
75
76 // Is Contact Name filter?
77 $this->assertContains($firstName, $this->getValue("sort_name_value"), "Filter Contact Name expected $firstName");
78
79 // Is Email Field?
80 $this->assertEquals("on", $this->getValue("fields[email]"));
81
82 // Is Phone Field?
83 $this->assertEquals("on", $this->getValue("fields[phone]"));
84
85 // Create report
86
87 $reportName = 'ContactSummary_' . substr(sha1(rand()), 0, 7);
88 $reportDescription = "New Contact Summary Report";
89 $emaiSubject = "Contact Summary Report";
90 $emailCC = "tesmail@example.org";
91
92 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[4]/a");
93 $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']");
94 $this->click("_qf_Summary_submit_save");
95
96 // Fill Report Title
97 $this->waitForElementPresent("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[1]/td[2]/input[@type='text']");
98 $this->type("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[1]/td[2]/input[@type='text']", $reportName);
99
100 // Fill Report Description
101 $this->waitForElementPresent("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[2]/td[2]/input[@type='text']");
102 $this->type("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[2]/td[2]/input[@type='text']", $reportDescription);
103 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
104 $this->waitForElementPresent('_qf_Summary_submit_save');
105
106 // Fill Email Subject
107 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[5]/a");
108 $this->waitForAjaxContent();
109 $this->type("email_subject", $emaiSubject);
110
111 // Fill Email To
112 $this->type("email_to", $emailId);
113
114 // Fill Email CC
115 $this->type("email_cc", $emailCC);
116
117 // We want navigation menu
118 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[6]/a");
119 $this->click("is_navigation");
120
121 // Navigation menu under Reports section
122 $this->waitForElementPresent("parent_id");
123 $this->select("parent_id", "label=Reports");
124
125 // Set permission as access CiviCRM
126 $this->waitForElementPresent("permission");
127 $this->select("permission", "value=access CiviCRM");
128
129 // click to create report
130 $this->click("_qf_Summary_submit_save");
131 $this->waitForPageToLoad($this->getTimeoutMsec());
132
133 // Open report list
134 $this->openCiviPage('report/list', 'reset=1');
135
136 // Is report is resent in list?
137 $this->assertElementContainsText('css=table.report-layout', $reportName);
138
139 // Visit report
140 $this->click("xpath=//div[@id='Contact']//table/tbody//tr/td/a/strong[text() = '$reportName']");
141 $this->waitForPageToLoad($this->getTimeoutMsec());
142
143 // Is filter statistics present?
144 $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
145
146 // Is Contact Name present in result?
147 $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
148
149 // Is email Id present on result?
150 $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
151
152 // check report criteria
153 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[3]/a");
154 $this->waitForElementPresent("sort_name_value");
155
156 // Is Contact Name filter?
157 $this->assertContains($firstName, $this->getValue("sort_name_value"), "Filter Contact Name expected $firstName");
158
159 // Is Email Field?
160 $this->assertEquals("on", $this->getValue("fields[email]"));
161
162 // Is Phone Field?
163 $this->assertEquals("on", $this->getValue("fields[phone]"));
164
165 // Check Report settings
166 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[4]/a");
167 $this->waitForElementPresent("title");
168
169 // Is correct Report Title?
170 $this->assertContains($reportName, $this->getValue("title"), "Report Title expected $reportName");
171
172 // Is correct Report Description?
173 $this->assertContains($reportDescription, $this->getValue("description"), "Report Description expected $reportDescription");
174
175 // Is correct email Subject?
176 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[5]/a");
177 $this->waitForAjaxContent();
178 $this->assertContains($emaiSubject, $this->getValue("email_subject"), "Email Subject expected $emaiSubject");
179
180 // Is correct email to?
181 $this->assertContains($emailId, $this->getValue("email_to"), "Email To expected $emailId");
182
183 // Is correct email cc?
184 $this->assertContains($emailCC, $this->getValue("email_cc"), "Email CC expected $emailCC");
185
186 // Is Navigation?
187 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[6]/a");
188 $this->assertEquals("on", $this->getValue("is_navigation"));
189
190 // Is correct Navigation Parent?
191 $this->assertSelectedLabel("parent_id", "Reports");
192
193 // Is correct access permission?
194 $this->assertSelectedLabel("permission", "access CiviCRM");
195 }
196
197 }