Commit | Line | Data |
---|---|---|
eeaee15d JP |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
eeaee15d | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
eeaee15d JP |
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 | */ |
eeaee15d JP |
26 | |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
28 | ||
29 | /** | |
30 | * Class WebTest_Case_AddCaseTest | |
31 | */ | |
32 | class WebTest_Case_AddCaseTypeTest extends CiviSeleniumTestCase { | |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testAddEditCaseType() { |
eeaee15d | 39 | $caseRoles = array(1 => 'Parent of', 2 => 'Spouse of', 3 => 'Partner of'); |
6c6e6187 TO |
40 | $activityTypes = array(1 => 'Meeting', 2 => 'Contribution', 3 => 'Event Registration'); |
41 | $timelineActivityTypes = array(1 => 'Meeting', 2 => 'Phone Call', 3 => 'Email'); | |
eeaee15d JP |
42 | // Log in as admin first to verify permissions for CiviCase |
43 | $this->webtestLogin('admin'); | |
44 | ||
45 | // Enable CiviCase module if necessary | |
46 | $this->enableComponents("CiviCase"); | |
47 | ||
48 | // let's give full CiviCase permissions to demo user (registered user). | |
92915c55 TO |
49 | $permission = array( |
50 | 'edit-2-access-all-cases-and-activities', | |
51 | 'edit-2-access-my-cases-and-activities', | |
52 | 'edit-2-administer-civicase', | |
c301f76e | 53 | 'edit-2-delete-in-civicase', |
92915c55 | 54 | ); |
eeaee15d JP |
55 | $this->changePermissions($permission); |
56 | ||
57 | // Log in as normal user | |
58 | $this->webtestLogin(); | |
59 | ||
60 | $this->openCiviPage('a/#/caseType/new'); | |
61 | ||
86bfa4f6 | 62 | $caseTypeLabel = "Case Type" . substr(sha1(rand()), 0, 7); |
eeaee15d JP |
63 | $this->waitForElementPresent('title'); |
64 | $this->type('title', $caseTypeLabel); | |
65 | ||
66 | foreach ($caseRoles as $cRoles) { | |
67 | $this->select2("xpath=//tr[@class='addRow']/td/span/div/a", $cRoles, FALSE, TRUE); | |
68 | } | |
69 | ||
70 | foreach ($activityTypes as $aType) { | |
fd4bd98d | 71 | $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity type']/div/a", $aType, FALSE, TRUE); |
eeaee15d JP |
72 | } |
73 | ||
74 | $this->click("xpath=//a[text()='Standard Timeline']"); | |
75 | foreach ($timelineActivityTypes as $tActivityType) { | |
fd4bd98d | 76 | $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity']/div/a", $tActivityType, FALSE, TRUE); |
eeaee15d JP |
77 | } |
78 | ||
ea83a78e | 79 | $this->click('css=.crm-submit-buttons button:first-child'); |
eeaee15d JP |
80 | |
81 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); | |
80f3b91d | 82 | $client = $this->createDialogContact("client_id"); |
eeaee15d JP |
83 | |
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); | |
9a24315b | 93 | $this->waitForElementPresent('case_type_id'); |
9a24315b | 94 | $this->waitForElementPresent('status_id'); |
16dc87ac | 95 | $this->select("case_type_id", "label=$caseTypeLabel"); |
eeaee15d | 96 | $this->select("status_id", "label={$caseStatusLabel}"); |
eeaee15d JP |
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 | ||
106 | foreach ($activityTypes as $aType) { | |
b18eb8e1 | 107 | $this->assertElementPresent("xpath=//div[@class='case-control-panel']/div/p/select", $aType); |
eeaee15d JP |
108 | } |
109 | ||
110 | $this->click("xpath=//div[contains(text(), 'Roles')]"); | |
9fdcdf6f | 111 | $this->waitForAjaxContent(); |
eeaee15d JP |
112 | |
113 | // check that expected roles are listed in the Case Roles pane | |
114 | foreach ($caseRoles as $key => $role) { | |
8a65f8da | 115 | $this->assertElementContainsText("css=div.crm-case-roles-block", $role); |
eeaee15d JP |
116 | } |
117 | ||
118 | $id = $this->urlArg('id'); | |
119 | // check that expected activities are listed in the Case Activities table | |
120 | foreach ($timelineActivityTypes as $tActivityType) { | |
8a65f8da | 121 | $this->assertElementContainsText("case_id_$id", $tActivityType); |
eeaee15d JP |
122 | } |
123 | ||
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')]"); | |
127 | ||
128 | $this->click("xpath=//table/tbody//tr/td[1][text()='{$caseTypeLabel}']/../td[5]/span/a[text()='Edit']"); | |
ea83a78e | 129 | $this->waitForElementPresent("css=.crm-submit-buttons button:first-child"); |
eeaee15d | 130 | |
86bfa4f6 | 131 | $editCaseTypeLabel = "Case Type Edit" . substr(sha1(rand()), 0, 7); |
eeaee15d JP |
132 | $this->waitForElementPresent('title'); |
133 | $this->type('title', $editCaseTypeLabel); | |
134 | ||
92915c55 | 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); |
9fdcdf6f | 136 | $this->click("xpath=//form[@name='editCaseTypeForm']/div/div[4]/table/tbody/tr[4]/td[2]/input[@type='checkbox']"); |
eeaee15d JP |
137 | |
138 | $this->click("xpath=//a[text()='Standard Timeline']"); | |
fd4bd98d | 139 | $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity']/div/a", 'SMS', FALSE, TRUE); |
eeaee15d | 140 | |
ea83a78e | 141 | $this->click('css=.crm-submit-buttons button:first-child'); |
eeaee15d JP |
142 | $this->waitForElementPresent("xpath=//*[@id='crm-main-content-wrapper']/div/div/div[2]/a/span[contains(text(),'New Case Type')]"); |
143 | ||
144 | $this->verifyText("xpath=//table/tbody//tr/td[contains(text(),'$editCaseTypeLabel')]", $editCaseTypeLabel); | |
145 | } | |
96025800 | 146 | |
eeaee15d | 147 | } |