Merge pull request #11742 from seanmadsen/NFC-CRM_PCP_Form_Event
[civicrm-core.git] / tests / phpunit / WebTest / Report / DonarReportTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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_DonarReportTest
31 */
32 class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testDonarReportPager() {
39 $this->webtestLogin();
40
41 // now create new donar detail report instance
42 $this->openCiviPage('report/contribute/detail', 'reset=1', '_qf_Detail_submit');
43
44 // preview result
45 $this->click("_qf_Detail_submit");
46 $this->waitForPageToLoad($this->getTimeoutMsec());
47
48 // Create report
49
50 $reportName = 'ContributeDetail_' . substr(sha1(rand()), 0, 7);
51 $reportDescription = "New Contribute Detail Report";
52
53 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[4]/a");
54 $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']");
55 $this->click("xpath=//div[@class='crm-submit-buttons']/input[@name='_qf_Detail_submit_save']");
56
57 // Fill Report Title
58 $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']");
59 $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);
60
61 // Fill Report Description
62 $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']");
63 $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);
64 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
65
66 // We want navigation menu
67 $this->waitForElementPresent('_qf_Detail_submit_next');
68 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[6]/a");
69 $this->click("is_navigation");
70 $this->waitForElementPresent("parent_id");
71
72 // Navigation menu under Reports section
73 $this->select("parent_id", "label=Reports");
74
75 // Set permission as access CiviCRM
76 $this->select("permission", "value=access CiviCRM");
77
78 // click to create report
79 $this->click("_qf_Detail_submit_save");
80 $this->waitForPageToLoad($this->getTimeoutMsec());
81
82 // Open report list
83 $this->openCiviPage('report/list', 'reset=1');
84
85 // Is report is resent in list?
86 $this->assertElementContainsText('css=div#Contribute > table.report-layout', $reportName);
87
88 // Visit report
89 $this->click("xpath=//div[@id='Contribute']//table/tbody//tr/td/a/strong[text() = '$reportName']");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
91
92 //now select the criteria
93 //click report criteria accordion
94 $this->click("xpath=//div[@id='mainTabContainer']/ul/li[3]/a");
95 $this->waitForElementPresent('_qf_Detail_submit_next');
96
97 //enter contribution amount
98 $this->waitForAjaxContent();
99 $this->select('total_amount_op', "value=gte");
100 $this->type('total_amount_value', "10");
101
102 // click preview
103 $this->click("_qf_Detail_submit");
104 $this->waitForPageToLoad($this->getTimeoutMsec());
105
106 //Is greater than or equal to 100
107 //check for criteria
108 $this->verifyText("xpath=//table[@class='report-layout statistics-table']/tbody/tr[3]/td", "Is greater than or equal to 10");
109
110 //click on next link
111 $this->click("_qf_Detail_submit");
112 $this->waitForPageToLoad($this->getTimeoutMsec());
113
114 // check if criteria still exits
115 $this->verifyText("xpath=//table[@class='report-layout statistics-table']/tbody/tr[3]/td", "Is greater than or equal to 10");
116 }
117
118 /**
119 * CRM-18484: To check the filter criteria 'is between'
120 */
121 public function testCheckIsBetweenFilter() {
122 $this->webtestLogin();
123
124 //add contact
125 $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel-bottom');
126 $firstName = 'Jo' . substr(sha1(rand()), 0, 4);
127 $lastName = 'Ad' . substr(sha1(rand()), 0, 7);
128 $this->type('first_name', $firstName);
129 $this->type('last_name', $lastName);
130
131 //address section
132 $this->click("xpath=//div[@id='addressBlockId']/div");
133 $this->waitForElementPresent("address_1_street_address");
134 $this->type("address_1_street_address", "902C El Camino Way SW");
135 $this->type("address_1_city", "Dumfries");
136 $this->type("address_1_postal_code", "1234");
137 $this->click("address_1_country_id");
138 $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
139 $this->click("_qf_Contact_upload_view-bottom");
140 $this->waitForPageToLoad($this->getTimeoutMsec());
141
142 $this->openCiviPage('report/instance/1', 'reset=1&output=criteria', '_qf_Summary_submit_csv');
143 $this->click("fields_postal_code");
144 $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Filters']");
145 $this->waitForElementPresent('gid_value');
146 $this->select('postal_code_op', "value=bw");
147 $this->waitForElementPresent('postal_code_max');
148 $this->type('postal_code_max', '1234');
149 $this->click("_qf_Summary_submit");
150 $this->waitForPageToLoad($this->getTimeoutMsec());
151 $this->assertElementContainsText("xpath=//table[@class='report-layout display']/tbody//tr/td[1]/a", "{$lastName}, {$firstName}");
152 }
153
154 }