Merge pull request #83 from pradpnayak/CRM-12024
[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->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom');
44 $enabledComponents = $this->getSelectOptions("enableComponents-t");
45 if (!in_array("CiviCase", $enabledComponents)) {
46 $this->addSelection("enableComponents-f", "label=CiviCase");
47 $this->click("//option[@value='CiviCase']");
48 $this->click("add");
49 $this->click("_qf_Component_next-bottom");
50 $this->waitForPageToLoad($this->getTimeoutMsec());
51 }
52
53 // let's give full CiviCase permissions to demo user (registered user).
54 $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');
55 $this->changePermissions($permission);
56
57 // Go directly to the URL of the screen that you will be testing (Dashboard).
58 $this->openCiviPage('case', 'reset=1', 'css=a.button');
59
60 // Should default to My Cases
61 $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
62 // The header text of the table changes too
63 $this->assertElementContainsText('crm-container', "Summary of Case Involvement");
64
65 $this->click("name=allupcoming value=1");
66 $this->waitForPageToLoad($this->getTimeoutMsec());
67 $this->waitForElementPresent("css=a.button");
68
69 $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
70 $this->assertElementContainsText('crm-container', "Summary of All Cases");
71
72 // Go back to dashboard
73 $this->openCiviPage('case', 'reset=1', 'css=a.button');
74
75 // Click on find my cases and check if right radio is checked
76 $this->click("name=find_my_cases");
77 $this->waitForPageToLoad($this->getTimeoutMsec());
78 $this->waitForElementPresent("css=input.form-submit");
79 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
80
81 // Go back to dashboard
82 $this->openCivipage('case', 'reset=1', 'css=a.button');
83
84 // Click on a drilldown cell and check if right radio is checked
85 $this->click("css=a.crm-case-summary-drilldown");
86 $this->waitForPageToLoad($this->getTimeoutMsec());
87 $this->waitForElementPresent("css=input.form-submit");
88 $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
89
90 // Go back to dashboard and reset to my cases
91 $this->openCiviPage('case', 'reset=1', 'css=a.button');
92 $this->click("name=allupcoming value=0");
93 $this->waitForPageToLoad($this->getTimeoutMsec());
94 $this->waitForElementPresent("css=a.button");
95
96 // Click on a drilldown cell and check if right radio is checked
97 $this->click("css=a.crm-case-summary-drilldown");
98 $this->waitForPageToLoad($this->getTimeoutMsec());
99 $this->waitForElementPresent("css=input.form-submit");
100 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
101 }
102 }
103