Import from SVN (r45945, r596)
[civicrm-core.git] / tests / phpunit / WebTest / Case / CaseDashboardTest.php
CommitLineData
6a488035
TO
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
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class 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->open($this->sboxPath . "civicrm/admin/setting/component?reset=1");
44 $this->waitForPageToLoad($this->getTimeoutMsec());
45 $this->waitForElementPresent("_qf_Component_next-bottom");
46 $enabledComponents = $this->getSelectOptions("enableComponents-t");
47 if (!in_array("CiviCase", $enabledComponents)) {
48 $this->addSelection("enableComponents-f", "label=CiviCase");
49 $this->click("//option[@value='CiviCase']");
50 $this->click("add");
51 $this->click("_qf_Component_next-bottom");
52 $this->waitForPageToLoad($this->getTimeoutMsec());
53 }
54
55 // let's give full CiviCase permissions to demo user (registered user).
56 $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');
57 $this->changePermissions($permission);
58
59 // Go directly to the URL of the screen that you will be testing (Dashboard).
60 $this->open($this->sboxPath . "civicrm/case?reset=1");
61
62 $this->waitForPageToLoad($this->getTimeoutMsec());
63 $this->waitForElementPresent("css=a.button");
64
65 // Should default to My Cases
66 $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
67 // The header text of the table changes too
68 $this->assertTextPresent("Summary of Case Involvement");
69
70 $this->click("name=allupcoming value=1");
71 $this->waitForPageToLoad($this->getTimeoutMsec());
72 $this->waitForElementPresent("css=a.button");
73
74 $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
75 $this->assertTextPresent("Summary of All Cases");
76
77 // Go back to dashboard
78 $this->open($this->sboxPath . "civicrm/case?reset=1");
79 $this->waitForPageToLoad($this->getTimeoutMsec());
80 $this->waitForElementPresent("css=a.button");
81
82 // Click on find my cases and check if right radio is checked
83 $this->click("name=find_my_cases");
84 $this->waitForPageToLoad($this->getTimeoutMsec());
85 $this->waitForElementPresent("css=input.form-submit");
86 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
87
88 // Go back to dashboard
89 $this->open($this->sboxPath . "civicrm/case?reset=1");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
91 $this->waitForElementPresent("css=a.button");
92
93 // Click on a drilldown cell and check if right radio is checked
94 $this->click("css=a.crm-case-summary-drilldown");
95 $this->waitForPageToLoad($this->getTimeoutMsec());
96 $this->waitForElementPresent("css=input.form-submit");
97 $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
98
99 // Go back to dashboard and reset to my cases
100 $this->open($this->sboxPath . "civicrm/case?reset=1");
101 $this->waitForPageToLoad($this->getTimeoutMsec());
102 $this->waitForElementPresent("css=a.button");
103 $this->click("name=allupcoming value=0");
104 $this->waitForPageToLoad($this->getTimeoutMsec());
105 $this->waitForElementPresent("css=a.button");
106
107 // Click on a drilldown cell and check if right radio is checked
108 $this->click("css=a.crm-case-summary-drilldown");
109 $this->waitForPageToLoad($this->getTimeoutMsec());
110 $this->waitForElementPresent("css=input.form-submit");
111 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
112 }
113}
114