Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Report_AddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Report_AddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testAddReport() { |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
41 | // create contact | |
42daf119 | 42 | $firstName = 'reportuser_' . substr(sha1(rand()), 0, 7); |
6a488035 | 43 | $displayName = "Anderson, $firstName"; |
42daf119 | 44 | $emailId = "$firstName.anderson@example.org"; |
6a488035 TO |
45 | $this->webtestAddContact($firstName, "Anderson", $emailId); |
46 | ||
481a74f4 | 47 | $this->openCiviPage('report/contact/summary', 'reset=1', '_qf_Summary_submit'); |
6a488035 TO |
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? | |
305515fb | 64 | $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!"); |
76e86fd8 | 65 | |
6a488035 | 66 | // Is Contact Name present in result? |
305515fb | 67 | $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!"); |
6a488035 TO |
68 | |
69 | // Is email Id present on result? | |
305515fb | 70 | $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!"); |
76e86fd8 | 71 | |
6a488035 | 72 | // check criteria |
f8c5cf0c | 73 | $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Filters']"); |
431bf520 | 74 | $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']"); |
6a488035 TO |
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 | |
6a488035 | 86 | |
42daf119 | 87 | $reportName = 'ContactSummary_' . substr(sha1(rand()), 0, 7); |
6a488035 | 88 | $reportDescription = "New Contact Summary Report"; |
42daf119 CW |
89 | $emaiSubject = "Contact Summary Report"; |
90 | $emailCC = "tesmail@example.org"; | |
f8c5cf0c | 91 | $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Developer']"); |
431bf520 RK |
92 | $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']"); |
93 | $this->click("_qf_Summary_submit_save"); | |
94 | ||
6a488035 | 95 | // Fill Report Title |
431bf520 RK |
96 | $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']"); |
97 | $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); | |
6a488035 TO |
98 | |
99 | // Fill Report Description | |
431bf520 RK |
100 | $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']"); |
101 | $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); | |
102 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]"); | |
103 | $this->waitForElementPresent('_qf_Summary_submit_save'); | |
6a488035 TO |
104 | |
105 | // Fill Email Subject | |
f8c5cf0c | 106 | $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Email Delivery']"); |
4a058f26 | 107 | $this->waitForAjaxContent(); |
6a488035 TO |
108 | $this->type("email_subject", $emaiSubject); |
109 | ||
110 | // Fill Email To | |
952cc48f | 111 | $this->waitForElementPresent('email_to'); |
6a488035 TO |
112 | $this->type("email_to", $emailId); |
113 | ||
114 | // Fill Email CC | |
952cc48f | 115 | $this->waitForElementPresent('email_cc'); |
6a488035 TO |
116 | $this->type("email_cc", $emailCC); |
117 | ||
118 | // We want navigation menu | |
f8c5cf0c | 119 | $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Access']"); |
f852aaf4 | 120 | $this->waitForAjaxContent(); |
6a488035 | 121 | $this->click("is_navigation"); |
6a488035 TO |
122 | |
123 | // Navigation menu under Reports section | |
431bf520 | 124 | $this->waitForElementPresent("parent_id"); |
6a488035 TO |
125 | $this->select("parent_id", "label=Reports"); |
126 | ||
127 | // Set permission as access CiviCRM | |
431bf520 | 128 | $this->waitForElementPresent("permission"); |
6a488035 TO |
129 | $this->select("permission", "value=access CiviCRM"); |
130 | ||
131 | // click to create report | |
132 | $this->click("_qf_Summary_submit_save"); | |
133 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
134 | ||
135 | // Open report list | |
305515fb | 136 | $this->openCiviPage('report/list', 'reset=1'); |
76e86fd8 | 137 | |
6a488035 | 138 | // Is report is resent in list? |
305515fb | 139 | $this->assertElementContainsText('css=table.report-layout', $reportName); |
6a488035 TO |
140 | |
141 | // Visit report | |
8cc4f1ab | 142 | $this->click("xpath=//div[@id='Contact']//table/tbody//tr/td/a/strong[text() = '$reportName']"); |
6a488035 | 143 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
621a73fa WA |
144 | $this->click("_qf_Summary_submit"); |
145 | $this->waitForAjaxContent(); | |
6c6e6187 | 146 | // Is filter statistics present? |
305515fb | 147 | $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!"); |
76e86fd8 | 148 | |
6a488035 | 149 | // Is Contact Name present in result? |
305515fb | 150 | $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!"); |
6a488035 TO |
151 | |
152 | // Is email Id present on result? | |
305515fb | 153 | $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!"); |
6a488035 TO |
154 | |
155 | // check report criteria | |
431bf520 | 156 | $this->click("xpath=//div[@id='mainTabContainer']/ul/li[3]/a"); |
6a488035 TO |
157 | $this->waitForElementPresent("sort_name_value"); |
158 | ||
159 | // Is Contact Name filter? | |
160 | $this->assertContains($firstName, $this->getValue("sort_name_value"), "Filter Contact Name expected $firstName"); | |
161 | ||
162 | // Is Email Field? | |
163 | $this->assertEquals("on", $this->getValue("fields[email]")); | |
164 | ||
165 | // Is Phone Field? | |
166 | $this->assertEquals("on", $this->getValue("fields[phone]")); | |
167 | ||
168 | // Check Report settings | |
f8c5cf0c | 169 | $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul/li[4]/a"); |
6a488035 TO |
170 | $this->waitForElementPresent("title"); |
171 | ||
172 | // Is correct Report Title? | |
173 | $this->assertContains($reportName, $this->getValue("title"), "Report Title expected $reportName"); | |
174 | ||
175 | // Is correct Report Description? | |
176 | $this->assertContains($reportDescription, $this->getValue("description"), "Report Description expected $reportDescription"); | |
177 | ||
178 | // Is correct email Subject? | |
03b0e225 | 179 | $this->waitForElementPresent("mainTabContainer"); |
f8c5cf0c | 180 | $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul/li[5]/a"); |
4a058f26 | 181 | $this->waitForAjaxContent(); |
6a488035 TO |
182 | $this->assertContains($emaiSubject, $this->getValue("email_subject"), "Email Subject expected $emaiSubject"); |
183 | ||
184 | // Is correct email to? | |
185 | $this->assertContains($emailId, $this->getValue("email_to"), "Email To expected $emailId"); | |
186 | ||
187 | // Is correct email cc? | |
188 | $this->assertContains($emailCC, $this->getValue("email_cc"), "Email CC expected $emailCC"); | |
189 | ||
190 | // Is Navigation? | |
f8c5cf0c | 191 | $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul/li[6]/a"); |
f852aaf4 | 192 | $this->waitForAjaxContent(); |
6a488035 TO |
193 | $this->assertEquals("on", $this->getValue("is_navigation")); |
194 | ||
195 | // Is correct Navigation Parent? | |
196 | $this->assertSelectedLabel("parent_id", "Reports"); | |
197 | ||
198 | // Is correct access permission? | |
199 | $this->assertSelectedLabel("permission", "access CiviCRM"); | |
200 | } | |
96025800 | 201 | |
6a488035 | 202 | } |