Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-06-23-14-48-29
[civicrm-core.git] / tests / phpunit / WebTest / Case / CaseDashboardTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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_Case_CaseDashboardTest
31 */
32 class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 function testAllOrMyCases() {
39 // Log in as admin first to verify permissions for CiviCase
40 $this->webtestLogin('true');
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 // Log in as normal user
50 $this->webtestLogin();
51
52 $this->openCiviPage('case', 'reset=1');
53
54 // Should default to My Cases
55 $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
56 // The header text of the table changes too
57 $this->assertElementContainsText('crm-container', "Summary of Involvement");
58
59 $this->clickLink("name=allupcoming value=1", "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->clickLink("name=find_my_cases", "css=input.form-submit");
69 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
70
71 // Go back to dashboard
72 $this->openCivipage('case', 'reset=1', 'css=a.button');
73
74 // Click on a drilldown cell and check if right radio is checked
75 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.form-submit");
76 $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
77
78 // Go back to dashboard and reset to my cases
79 $this->openCiviPage('case', 'reset=1', 'css=a.button');
80 $this->clickLink("name=allupcoming value=0", "css=a.button");
81
82 // Click on a drilldown cell and check if right radio is checked
83 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.form-submit");
84 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
85 }
86 }
87