phpcs - Fix error, "Expected 1 newline at end of file; XXX found".
[civicrm-core.git] / tests / phpunit / WebTest / Case / CaseDashboardTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
06a1bc01 6 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
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
6a488035 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Case_CaseDashboardTest
31 */
6a488035
TO
32class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
00be9182 38 public function testAllOrMyCases() {
6a488035 39 // Log in as admin first to verify permissions for CiviCase
80f3b91d 40 $this->webtestLogin('admin');
6a488035
TO
41
42 // Enable CiviCase module if necessary
b9715b8a 43 $this->enableComponents("CiviCase");
6a488035
TO
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
42daf119
CW
49 // Log in as normal user
50 $this->webtestLogin();
51
52 $this->openCiviPage('case', 'reset=1');
6a488035
TO
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
0e71b04f 57 $this->assertElementContainsText('crm-container', "Summary of Involvement");
6a488035 58
225a8648 59 $this->clickLink("name=allupcoming value=1", "css=a.button");
6a488035
TO
60
61 $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
d2771e94 62 $this->assertElementContainsText('crm-container', "Summary of All Cases");
6a488035
TO
63
64 // Go back to dashboard
d2771e94 65 $this->openCiviPage('case', 'reset=1', 'css=a.button');
6a488035
TO
66
67 // Click on find my cases and check if right radio is checked
97e557d7 68 $this->clickLink("name=find_my_cases", "css=input.crm-form-submit");
6a488035
TO
69 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
70
2913f26f 71 //Add case to get drilldown cell on Case dashboard
72 $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
73
2913f26f 74 // We're using pop-up New Contact dialog
80f3b91d 75 $this->createDialogContact('client_id');
2913f26f 76
77 // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
78 $caseTypeLabel = "Adult Day Care Referral";
79 // activity types we expect for this case type
80 $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation");
81 $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client");
82 $caseStatusLabel = "Ongoing";
83 $subject = "Safe daytime setting - senior female";
84 $this->select("medium_id", "value=1");
85 $location = "Main offices";
86 $this->type("activity_location", $location);
87 $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
88 $this->fireEvent('activity_details', 'focus');
89 $this->fillRichTextField("activity_details", $details, 'CKEditor');
90 $this->type("activity_subject", $subject);
91
92 $this->select("case_type_id", "label={$caseTypeLabel}");
93 $this->select("status_id", "label={$caseStatusLabel}");
94
95 // Choose Case Start Date.
96 // Using helper webtestFillDate function.
97 $this->webtestFillDate('start_date', 'now');
98 $today = date('F jS, Y', strtotime('now'));
99
100 $this->type("duration", "20");
101 $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom");
102
103 // Is status message correct?
104 $this->waitForText('crm-notification-container', "Case opened successfully.");
105
6a488035 106 // Go back to dashboard
59843a57 107 $this->openCiviPage('case', 'reset=1');
6a488035
TO
108
109 // Click on a drilldown cell and check if right radio is checked
97e557d7 110 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit");
6a488035
TO
111 $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
112
113 // Go back to dashboard and reset to my cases
d2771e94 114 $this->openCiviPage('case', 'reset=1', 'css=a.button');
225a8648 115 $this->clickLink("name=allupcoming value=0", "css=a.button");
6a488035
TO
116
117 // Click on a drilldown cell and check if right radio is checked
97e557d7 118 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit");
6a488035
TO
119 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
120 }
121}