The cut-n-paste code avanger strikes again
[civicrm-core.git] / tests / phpunit / WebTest / Case / CaseDashboardTest.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_Case_CaseDashboardTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testAllOrMyCases() {
36
37 $this->open($this->sboxPath);
38
39 // Log in as admin first to verify permissions for CiviCase
40 $this->webtestLogin();
41
42 // Enable CiviCase module if necessary
43 $this->enableComponents("CiviCase");
44
45 // let's give full CiviCase permissions to demo user (registered user).
46 $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase');
47 $this->changePermissions($permission);
48
49 // Go directly to the URL of the screen that you will be testing (Dashboard).
50 $this->openCiviPage('case', 'reset=1', 'css=a.button');
51
52 // Should default to My Cases
53 $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
54 // The header text of the table changes too
55 $this->assertElementContainsText('crm-container', "Summary of Case Involvement");
56
57 $this->click("name=allupcoming value=1");
58 $this->waitForPageToLoad($this->getTimeoutMsec());
59 $this->waitForElementPresent("css=a.button");
60
61 $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
62 $this->assertElementContainsText('crm-container', "Summary of All Cases");
63
64 // Go back to dashboard
65 $this->openCiviPage('case', 'reset=1', 'css=a.button');
66
67 // Click on find my cases and check if right radio is checked
68 $this->click("name=find_my_cases");
69 $this->waitForPageToLoad($this->getTimeoutMsec());
70 $this->waitForElementPresent("css=input.form-submit");
71 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
72
73 // Go back to dashboard
74 $this->openCivipage('case', 'reset=1', 'css=a.button');
75
76 // Click on a drilldown cell and check if right radio is checked
77 $this->click("css=a.crm-case-summary-drilldown");
78 $this->waitForPageToLoad($this->getTimeoutMsec());
79 $this->waitForElementPresent("css=input.form-submit");
80 $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
81
82 // Go back to dashboard and reset to my cases
83 $this->openCiviPage('case', 'reset=1', 'css=a.button');
84 $this->click("name=allupcoming value=0");
85 $this->waitForPageToLoad($this->getTimeoutMsec());
86 $this->waitForElementPresent("css=a.button");
87
88 // Click on a drilldown cell and check if right radio is checked
89 $this->click("css=a.crm-case-summary-drilldown");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
91 $this->waitForElementPresent("css=input.form-submit");
92 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
93 }
94 }
95