Merge pull request #89 from colemanw/d6
[civicrm-core.git] / tests / phpunit / WebTest / Report / DonarReportTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testDonarReportPager() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
38 // class attributes.
39 $this->open($this->sboxPath);
40
41 // Logging in. Remember to wait for page to load. In most cases,
42 // you can rely on 30000 as the value that allows your test to pass, however,
43 // sometimes your test might fail because of this. In such cases, it's better to pick one element
44 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
45 // page contents loaded and you can continue your test execution.
46 $this->webtestLogin();
47
48 // now create new donar detail report instance
49 $this->openCiviPage('report/contribute/detail', 'reset=1', '_qf_Detail_submit');
50
51 // preview result
52 $this->click("_qf_Detail_submit");
53 $this->waitForPageToLoad($this->getTimeoutMsec());
54
55 // Create report
56 $this->click("css=div.crm-report_setting-accordion div.crm-accordion-header");
57 $this->waitForElementPresent("title");
58
59 $reportName = 'ContributeDetail_' . substr(sha1(rand()), 0, 7);
60 $reportDescription = "New Contribute Detail Report";
61
62 // Fill Report Title
63 $this->type("title", $reportName);
64
65 // Fill Report Description
66 $this->type("description", $reportDescription);
67
68 // We want navigation menu
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("link=$reportName");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
91
92 //now select the criteria
93 //click report criteria accordian
94 $this->click("css=div.crm-report_criteria-accordion div.crm-accordion-header");
95
96 //enter contribution amount
97 $this->select('total_amount_op', "value=gte");
98 $this->type('total_amount_value', "10");
99
100 // click preview
101 $this->click("_qf_Detail_submit");
102 $this->waitForPageToLoad($this->getTimeoutMsec());
103
104 //Is greater than or equal to 100
105 //check for criteria
106 $this->assertElementContainsText('css=table.statistics-table', "Is greater than or equal to 10", "Criteria is not selected");
107
108 //click on next link
109 $this->click("_qf_Detail_submit_save");
110 $this->waitForPageToLoad($this->getTimeoutMsec());
111
112 // check if criteria still exits
113 $this->assertElementContainsText('css=table.statistics-table', "Is greater than or equal to 10", "Criteria is not selected");
114 }
115 }