3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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_AddCaseTest
32 class WebTest_Case_AddCaseTypeTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testAddEditCaseType() {
39 $caseRoles = array(1 => 'Parent of', 2 => 'Spouse of', 3 => 'Partner of');
40 $activityTypes = array(1 => 'Meeting', 2 => 'Contribution', 3 => 'Event Registration');
41 $timelineActivityTypes = array(1 => 'Meeting', 2 => 'Phone Call', 3 => 'Email');
42 // Log in as admin first to verify permissions for CiviCase
43 $this->webtestLogin('admin');
45 // Enable CiviCase module if necessary
46 $this->enableComponents("CiviCase");
48 // let's give full CiviCase permissions to demo user (registered user).
50 'edit-2-access-all-cases-and-activities',
51 'edit-2-access-my-cases-and-activities',
52 'edit-2-administer-civicase',
53 'edit-2-delete-in-civicase',
55 $this->changePermissions($permission);
57 // Log in as normal user
58 $this->webtestLogin();
60 $this->openCiviPage('a/#/caseType/new');
62 $caseTypeLabel = "Case Type" . substr(sha1(rand()), 0, 7);
63 $this->waitForElementPresent('title');
64 $this->type('title', $caseTypeLabel);
66 foreach ($caseRoles as $cRoles) {
67 $this->select2("xpath=//tr[@class='addRow']/td/span/div/a", $cRoles, FALSE, TRUE);
70 foreach ($activityTypes as $aType) {
71 $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity type']/div/a", $aType, FALSE, TRUE);
74 $this->click("xpath=//a[text()='Standard Timeline']");
75 foreach ($timelineActivityTypes as $tActivityType) {
76 $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity']/div/a", $tActivityType, FALSE, TRUE);
79 $this->click('css=.crm-submit-buttons button:first-child');
81 $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
82 $client = $this->createDialogContact("client_id");
84 $caseStatusLabel = "Ongoing";
85 $subject = "Safe daytime setting - senior female";
86 $this->select("medium_id", "value=1");
87 $location = "Main offices";
88 $this->type("activity_location", $location);
89 $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
90 $this->fireEvent('activity_details', 'focus');
91 $this->fillRichTextField("activity_details", $details, 'CKEditor');
92 $this->type("activity_subject", $subject);
93 $this->waitForElementPresent('case_type_id');
94 $this->select("case_type_id", "label={$caseTypeLabel}");
95 $this->waitForElementPresent('status_id');
96 $this->select("status_id", "label={$caseStatusLabel}");
98 $this->webtestFillDate('start_date', 'now');
99 $today = date('F jS, Y', strtotime('now'));
101 $this->type("duration", "20");
102 $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom");
104 // Is status message correct?
105 $this->waitForText('crm-notification-container', "Case opened successfully.");
107 foreach ($activityTypes as $aType) {
108 $this->assertElementPresent("xpath=//div[@class='case-control-panel']/div/p/select", $aType);
111 $this->click("xpath=//div[contains(text(), 'Roles')]");
113 // check that expected roles are listed in the Case Roles pane
114 foreach ($caseRoles as $key => $role) {
115 $this->assertText("css=div.crm-case-roles-block", $role);
118 $id = $this->urlArg('id');
119 // check that expected activities are listed in the Case Activities table
120 foreach ($timelineActivityTypes as $tActivityType) {
121 $this->assertText("case_id_$id", $tActivityType);
124 // for edit case type
125 $this->openCiviPage('a/#/caseType');
126 $this->waitForElementPresent("xpath=//*[@id='crm-main-content-wrapper']/div/div/div[2]/a/span[contains(text(),'New Case Type')]");
128 $this->click("xpath=//table/tbody//tr/td[1][text()='{$caseTypeLabel}']/../td[5]/span/a[text()='Edit']");
129 $this->waitForElementPresent("css=.crm-submit-buttons button:first-child");
131 $editCaseTypeLabel = "Case Type Edit" . substr(sha1(rand()), 0, 7);
132 $this->waitForElementPresent('title');
133 $this->type('title', $editCaseTypeLabel);
135 $this->select2("xpath=//div[@id='crm-main-content-wrapper']/div/div/form/div/div[4]/table/tfoot/tr/td/span/div/a", 'Sibling of', FALSE, TRUE);
136 $this->click("xpath=//*[@id='crm-main-content-wrapper']/div/div/form/div/div[4]/table/tbody/tr[4]/td[2]/input[@type='checkbox']");
138 $this->click("xpath=//a[text()='Standard Timeline']");
139 $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity']/div/a", 'SMS', FALSE, TRUE);
141 $this->click('css=.crm-submit-buttons button:first-child');
142 $this->waitForElementPresent("xpath=//*[@id='crm-main-content-wrapper']/div/div/div[2]/a/span[contains(text(),'New Case Type')]");
144 $this->verifyText("xpath=//table/tbody//tr/td[contains(text(),'$editCaseTypeLabel')]", $editCaseTypeLabel);