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_Campaign_ActivityTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Campaign_ActivityTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testCreateCampaign() { |
a49e5dea | 39 | $this->markTestSkipped('Skipping for now as it works fine locally.'); |
42daf119 | 40 | $this->webtestLogin('admin'); |
6a488035 TO |
41 | |
42 | // Enable CiviCampaign module if necessary | |
8f737a72 | 43 | $this->enableComponents(array('CiviCampaign')); |
6a488035 TO |
44 | |
45 | // add the required Drupal permission | |
46 | $permissions = array('edit-2-administer-civicampaign'); | |
47 | $this->changePermissions($permissions); | |
48 | ||
42daf119 CW |
49 | // Log in as normal user |
50 | $this->webtestLogin(); | |
51 | ||
6a488035 TO |
52 | // Create new group |
53 | $title = substr(sha1(rand()), 0, 7); | |
54 | $groupName = $this->WebtestAddGroup(); | |
55 | ||
56 | // Adding contact | |
57 | // We're using Quick Add block on the main page for this. | |
58 | $firstName1 = substr(sha1(rand()), 0, 7); | |
59 | $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org"); | |
60 | ||
61 | // add contact to group | |
62 | // visit group tab | |
63 | $this->click("css=li#tab_group a"); | |
64 | $this->waitForElementPresent("group_id"); | |
65 | ||
66 | // add to group | |
67 | $this->select("group_id", "label=$groupName"); | |
68 | $this->click("_qf_GroupContact_next"); | |
2af8120a | 69 | $this->waitForElementPresent('link=Remove'); |
6a488035 TO |
70 | |
71 | $firstName2 = substr(sha1(rand()), 0, 7); | |
72 | $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org"); | |
73 | ||
74 | // add contact to group | |
75 | // visit group tab | |
76 | $this->click("css=li#tab_group a"); | |
77 | $this->waitForElementPresent("group_id"); | |
78 | ||
79 | // add to group | |
80 | $this->select("group_id", "label=$groupName"); | |
81 | $this->click("_qf_GroupContact_next"); | |
2af8120a | 82 | $this->waitForElementPresent('link=Remove'); |
6a488035 | 83 | |
8f737a72 | 84 | $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom'); |
6a488035 | 85 | |
6a488035 TO |
86 | $campaignTitle = "Campaign " . $title; |
87 | $this->type("title", $campaignTitle); | |
88 | ||
89 | // select the campaign type | |
90 | $this->select("campaign_type_id", "value=2"); | |
91 | ||
92 | // fill in the description | |
93 | $this->type("description", "This is a test campaign"); | |
94 | ||
95 | // include groups for the campaign | |
ba6f320f | 96 | $this->multiselect2("includeGroups", array("$groupName", "Advisory Board")); |
6a488035 TO |
97 | |
98 | // fill the end date for campaign | |
99 | $this->webtestFillDate("end_date", "+1 year"); | |
100 | ||
101 | // select campaign status | |
102 | $this->select("status_id", "value=2"); | |
103 | ||
104 | // click save | |
105 | $this->click("_qf_Campaign_upload-bottom"); | |
106 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
107 | ||
6c5f7368 | 108 | $this->waitForText('crm-notification-container', "Campaign $title"); |
6a488035 | 109 | |
131d5a64 WA |
110 | $this->waitForElementPresent("xpath=//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]"); |
111 | $id = (int) $this->getText("xpath=//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]"); | |
6a488035 TO |
112 | $this->activityAddTest($campaignTitle, $id); |
113 | } | |
114 | ||
4cbe18b8 EM |
115 | /** |
116 | * @param $campaignTitle | |
100fef9d | 117 | * @param int $id |
4cbe18b8 | 118 | */ |
00be9182 | 119 | public function activityAddTest($campaignTitle, $id) { |
6a488035 TO |
120 | // Adding Adding contact with randomized first name for test testContactContextActivityAdd |
121 | // We're using Quick Add block on the main page for this. | |
122 | $firstName1 = substr(sha1(rand()), 0, 7); | |
123 | $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name"); | |
124 | $firstName2 = substr(sha1(rand()), 0, 7); | |
125 | $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); | |
126 | ||
6a488035 TO |
127 | $this->click("css=li#tab_activity a"); |
128 | ||
129 | // waiting for the activity dropdown to show up | |
130 | $this->waitForElementPresent("other_activity"); | |
131 | ||
132 | // Select the activity type from the activity dropdown | |
133 | $this->select("other_activity", "label=Meeting"); | |
134 | ||
135 | // waitForPageToLoad is not always reliable. Below, we're waiting for the submit | |
136 | // button at the end of this page to show up, to make sure it's fully loaded. | |
137 | $this->waitForElementPresent("_qf_Activity_upload"); | |
138 | ||
6a488035 | 139 | // ...and verifying if the page contains properly formatted display name for chosen contact. |
2af8120a AS |
140 | $this->waitForElementPresent("//*[@id='s2id_target_contact_id']"); |
141 | $this->assertElementContainsText('//*[@id="s2id_target_contact_id"]/ul/li[1]/div', 'Anderson, ' . $firstName2, 'Contact not found in line ' . __LINE__); | |
6a488035 TO |
142 | |
143 | // Now we're filling the "Assigned To" field. | |
144 | // Typing contact's name into the field (using typeKeys(), not type()!)... | |
2af8120a | 145 | $this->select2("assignee_contact_id", $firstName1, TRUE); |
6a488035 TO |
146 | |
147 | // ...and verifying if the page contains properly formatted display name for chosen contact. | |
2af8120a AS |
148 | $this->waitForElementPresent("//*[@id='s2id_assignee_contact_id']"); |
149 | $this->assertElementContainsText('//*[@id="s2id_assignee_contact_id"]/ul/li[1]/div', 'Summerson, ' . $firstName1, 'Contact not found in line ' . __LINE__); | |
6a488035 TO |
150 | |
151 | // Since we're here, let's check if screen help is being displayed properly | |
2af8120a | 152 | //$this->assertTrue($this->isTextPresent("A copy of this activity will be emailed to each Assignee")); |
6a488035 TO |
153 | |
154 | // Putting the contents into subject field - assigning the text to variable, it'll come in handy later | |
155 | $subject = "This is subject of test activity being added through activity tab of contact summary screen."; | |
156 | // For simple input fields we can use field id as selector | |
157 | $this->type("subject", $subject); | |
158 | ||
159 | // select campaign | |
39c74f87 | 160 | $this->waitForElementPresent("campaign_id"); |
6a488035 TO |
161 | $this->click("campaign_id"); |
162 | $this->select("campaign_id", "value=$id"); | |
163 | ||
164 | $this->type("location", "Some location needs to be put in this field."); | |
165 | ||
166 | // Choosing the Date. | |
167 | // Please note that we don't want to put in fixed date, since | |
168 | // we want this test to work in the future and not fail because | |
169 | // of date being set in the past. Therefore, using helper webtestFillDateTime function. | |
170 | $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM'); | |
171 | ||
172 | // Setting duration. | |
173 | $this->type("duration", "30"); | |
174 | ||
175 | // Putting in details. | |
176 | $this->type("details", "Really brief details information."); | |
177 | ||
178 | // Making sure that status is set to Scheduled (using value, not label). | |
179 | $this->select("status_id", "value=1"); | |
180 | ||
181 | // Setting priority. | |
182 | $this->select("priority_id", "value=1"); | |
183 | ||
184 | // Adding attachment | |
185 | // TODO TBD | |
186 | ||
187 | // Scheduling follow-up. | |
188 | $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header"); | |
189 | $this->select("followup_activity_type_id", "value=1"); | |
190 | $this->webtestFillDateTime('followup_date', '+1 month 11:10PM'); | |
191 | $this->type("followup_activity_subject", "This is subject of schedule follow-up activity"); | |
192 | ||
193 | // Clicking save. | |
6c6e6187 | 194 | $this->clickLink("_qf_Activity_upload", 'link=View', FALSE); |
6a488035 TO |
195 | |
196 | // Is status message correct? | |
6c5f7368 | 197 | $this->waitForText('crm-notification-container', $subject); |
6a488035 | 198 | |
05e39ac3 | 199 | $this->waitForElementPresent("xpath=//div[@class='crm-activity-selector-activity']/div[2]/table/tbody/tr[2]/td[8]/span[1]/a[1][text()='View']"); |
6a488035 TO |
200 | |
201 | // click through to the Activity view screen | |
05e39ac3 | 202 | $this->click("xpath=//div[@class='crm-activity-selector-activity']/div[2]/table/tbody/tr[2]/td[8]/span[1]/a[1][text()='View']"); |
e7066c8e | 203 | $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]"); |
76e86fd8 | 204 | |
6a488035 | 205 | // verify Activity created |
03b0e225 | 206 | $this->waitForAjaxContent(); |
371f954c | 207 | $this->verifyText("xpath=//form[@id='Activity']/div[2]/table/tbody/tr[5]/td[2]/span", $campaignTitle); |
6a488035 | 208 | } |
96025800 | 209 | |
6a488035 | 210 | } |