3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Case_CaseDashboardTest
32 class WebTest_Case_CaseDashboardTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testAllOrMyCases() {
39 // Log in as admin first to verify permissions for CiviCase
40 $this->webtestLogin('admin');
42 // Enable CiviCase module if necessary
43 $this->enableComponents("CiviCase");
45 // let's give full CiviCase permissions to demo user (registered user).
47 'edit-2-access-all-cases-and-activities',
48 'edit-2-access-my-cases-and-activities',
49 'edit-2-administer-civicase',
50 'edit-2-delete-in-civicase',
52 $this->changePermissions($permission);
54 // Log in as normal user
55 $this->webtestLogin();
57 $this->openCiviPage('case', 'reset=1');
59 // Should default to My Cases
60 $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
61 // The header text of the table changes too
62 $this->assertElementContainsText('crm-container', "Summary of Involvement");
64 $this->clickLink("name=allupcoming value=1", "css=a.button");
66 $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
67 $this->assertElementContainsText('crm-container', "Summary of All Cases");
69 // Go back to dashboard
70 $this->openCiviPage('case', 'reset=1', 'css=a.button');
72 // Click on find my cases and check if right radio is checked
73 $this->clickLink("name=find_my_cases", "css=input.crm-form-submit");
74 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
76 //Add case to get drilldown cell on Case dashboard
77 $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
79 // We're using pop-up New Contact dialog
80 $this->createDialogContact('client_id');
82 // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
83 $caseTypeLabel = "Adult Day Care Referral";
84 // activity types we expect for this case type
85 $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation");
86 $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client");
87 $caseStatusLabel = "Ongoing";
88 $subject = "Safe daytime setting - senior female";
89 $this->select("medium_id", "value=1");
90 $location = "Main offices";
91 $this->type("activity_location", $location);
92 $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
93 $this->fireEvent('activity_details', 'focus');
94 $this->fillRichTextField("activity_details", $details, 'CKEditor');
95 $this->type("activity_subject", $subject);
97 $this->select("case_type_id", "label={$caseTypeLabel}");
98 $this->select("status_id", "label={$caseStatusLabel}");
100 // Choose Case Start Date.
101 // Using helper webtestFillDate function.
102 $this->webtestFillDate('start_date', 'now');
103 $today = date('F jS, Y', strtotime('now'));
105 $this->type("duration", "20");
106 $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom");
108 // Is status message correct?
109 $this->waitForText('crm-notification-container', "Case opened successfully.");
111 // Go back to dashboard
112 $this->openCiviPage('case', 'reset=1');
114 // Click on a drilldown cell and check if right radio is checked
115 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit");
116 $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
118 // Go back to dashboard and reset to my cases
119 $this->openCiviPage('case', 'reset=1', 'css=a.button');
120 $this->clickLink("name=allupcoming value=0", "css=a.button");
122 // Click on a drilldown cell and check if right radio is checked
123 $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit");
124 $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');