Merge pull request #2003 from lcdservices/CRM-13781
[civicrm-core.git] / tests / phpunit / WebTest / Case / CaseDashboardTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testAllOrMyCases() {
35 // Log in as admin first to verify permissions for CiviCase
36 $this->webtestLogin('true');
37
38 // Enable CiviCase module if necessary
39 $this->enableComponents("CiviCase");
40
41 // let's give full CiviCase permissions to demo user (registered user).
42 $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');
43 $this->changePermissions($permission);
44
45 // Log in as normal user
46 $this->webtestLogin();
47
48 $this->openCiviPage('case', 'reset=1');
49
50 // Should default to My Cases
51 $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
52 // The header text of the table changes too
53 $this->assertElementContainsText('crm-container', "Summary of Involvement");
54
55 $this->clickLink("name=allupcoming value=1", "css=a.button");
56
57 $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
58 $this->assertElementContainsText('crm-container', "Summary of All Cases");
59
60 // Go back to dashboard
61 $this->openCiviPage('case', 'reset=1', 'css=a.button');
62
63 // Click on find my cases and check if right radio is checked
64 $this->clickLink("name=find_my_cases", "css=input.form-submit");
65 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
66
67 // Go back to dashboard
68 $this->openCivipage('case', 'reset=1', 'css=a.button');
69
70 // Click on a drilldown cell and check if right radio is checked
71 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.form-submit");
72 $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
73
74 // Go back to dashboard and reset to my cases
75 $this->openCiviPage('case', 'reset=1', 'css=a.button');
76 $this->clickLink("name=allupcoming value=0", "css=a.button");
77
78 // Click on a drilldown cell and check if right radio is checked
79 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.form-submit");
80 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
81 }
82 }
83