Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Case_CaseDashboardTest | |
31 | */ | |
6a488035 TO |
32 | class 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). | |
92915c55 TO |
46 | $permission = array( |
47 | 'edit-2-access-all-cases-and-activities', | |
48 | 'edit-2-access-my-cases-and-activities', | |
49 | 'edit-2-administer-civicase', | |
3bdca100 | 50 | 'edit-2-delete-in-civicase', |
92915c55 | 51 | ); |
6a488035 TO |
52 | $this->changePermissions($permission); |
53 | ||
42daf119 CW |
54 | // Log in as normal user |
55 | $this->webtestLogin(); | |
56 | ||
57 | $this->openCiviPage('case', 'reset=1'); | |
6a488035 TO |
58 | |
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 | |
0e71b04f | 62 | $this->assertElementContainsText('crm-container', "Summary of Involvement"); |
6a488035 | 63 | |
225a8648 | 64 | $this->clickLink("name=allupcoming value=1", "css=a.button"); |
6a488035 TO |
65 | |
66 | $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.'); | |
d2771e94 | 67 | $this->assertElementContainsText('crm-container', "Summary of All Cases"); |
6a488035 TO |
68 | |
69 | // Go back to dashboard | |
d2771e94 | 70 | $this->openCiviPage('case', 'reset=1', 'css=a.button'); |
6a488035 TO |
71 | |
72 | // Click on find my cases and check if right radio is checked | |
97e557d7 | 73 | $this->clickLink("name=find_my_cases", "css=input.crm-form-submit"); |
6a488035 TO |
74 | $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.'); |
75 | ||
2913f26f | 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'); | |
78 | ||
2913f26f | 79 | // We're using pop-up New Contact dialog |
df393c14 | 80 | $params = $this->createDialogContact('client_id'); |
2913f26f | 81 | |
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); | |
96 | ||
97 | $this->select("case_type_id", "label={$caseTypeLabel}"); | |
98 | $this->select("status_id", "label={$caseStatusLabel}"); | |
99 | ||
100 | // Choose Case Start Date. | |
101 | // Using helper webtestFillDate function. | |
102 | $this->webtestFillDate('start_date', 'now'); | |
103 | $today = date('F jS, Y', strtotime('now')); | |
104 | ||
105 | $this->type("duration", "20"); | |
106 | $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom"); | |
107 | ||
108 | // Is status message correct? | |
109 | $this->waitForText('crm-notification-container', "Case opened successfully."); | |
110 | ||
df393c14 | 111 | // Go back to dashboard |
112 | $this->openCiviPage('case', 'reset=1'); | |
113 | //Check whether case status link opens in search correctly | |
114 | $this->clickLink("xpath=//table[@class='report']/tbody/tr[3]/td/a"); | |
115 | $this->assertElementContainsText('Search', "{$params['last_name']}, {$params['first_name']}"); | |
116 | ||
6a488035 | 117 | // Go back to dashboard |
59843a57 | 118 | $this->openCiviPage('case', 'reset=1'); |
6a488035 TO |
119 | |
120 | // Click on a drilldown cell and check if right radio is checked | |
97e557d7 | 121 | $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit"); |
6a488035 TO |
122 | $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.'); |
123 | ||
124 | // Go back to dashboard and reset to my cases | |
d2771e94 | 125 | $this->openCiviPage('case', 'reset=1', 'css=a.button'); |
225a8648 | 126 | $this->clickLink("name=allupcoming value=0", "css=a.button"); |
6a488035 TO |
127 | |
128 | // Click on a drilldown cell and check if right radio is checked | |
97e557d7 | 129 | $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit"); |
6a488035 TO |
130 | $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.'); |
131 | } | |
96025800 | 132 | |
6a488035 | 133 | } |