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_PetitionUsageScenarioTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { |
33 | ||
6a488035 TO |
34 | protected function setUp() { |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testPetitionUsageScenario() { |
a49e5dea | 39 | $this->markTestSkipped('Skipping for now as it works fine locally.'); |
42daf119 | 40 | $this->webtestLogin('admin'); |
6a488035 | 41 | |
6a488035 | 42 | // Enable CiviCampaign module if necessary |
b9715b8a | 43 | $this->enableComponents("CiviCampaign"); |
6a488035 TO |
44 | |
45 | // handle permissions early | |
46 | ||
47 | // let's give permission 'sign CiviCRM Petition' to anonymous user. | |
48 | $permissions = array( | |
49 | // give profile related permision | |
50 | "edit-1-sign-civicrm-petition", | |
51 | "edit-1-profile-create", | |
52 | "edit-1-profile-edit", | |
53 | "edit-1-profile-listings", | |
54 | "edit-1-profile-view", | |
55 | // now give full permissions to CiviPetition to registered user | |
56 | "edit-2-administer-civicampaign", | |
57 | "edit-2-manage-campaign", | |
58 | "edit-2-gotv-campaign-contacts", | |
59 | "edit-2-interview-campaign-contacts", | |
60 | "edit-2-release-campaign-contacts", | |
61 | "edit-2-reserve-campaign-contacts", | |
62 | "edit-2-sign-civicrm-petition", | |
63 | ); | |
64 | $this->changePermissions($permissions); | |
65 | ||
42daf119 CW |
66 | // Log in as normal user |
67 | $this->webtestLogin(); | |
6a488035 | 68 | |
42daf119 | 69 | /////////////// Create Campaign /////////////////////////////// |
6a488035 | 70 | |
42daf119 | 71 | $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); |
6a488035 | 72 | |
6a488035 TO |
73 | $title = substr(sha1(rand()), 0, 7); |
74 | $this->type("title", "$title Campaign"); | |
75 | ||
76 | // select the campaign type | |
77 | $this->select("campaign_type_id", "value=2"); | |
78 | ||
79 | // fill in the description | |
80 | $this->type("description", "This is a test campaign"); | |
81 | ||
82 | // include groups for the campaign | |
fe725ccb | 83 | $this->addSelection("includeGroups", "label=Advisory Board"); |
6a488035 | 84 | $this->click("//option[@value=4]"); |
6a488035 TO |
85 | |
86 | // fill the end date for campaign | |
87 | $this->webtestFillDate("end_date", "+1 year"); | |
88 | ||
89 | // select campaign status | |
90 | $this->select("status_id", "value=2"); | |
91 | ||
92 | // click save | |
d226f7d8 | 93 | $this->clickLink('_qf_Campaign_upload-bottom'); |
6a488035 | 94 | |
d226f7d8 | 95 | $this->waitForText('crm-notification-container', "Campaign $title Campaign has been saved."); |
6a488035 TO |
96 | |
97 | ////////////// Create petition using New Individual profile ////////////////////// | |
98 | ||
071a6d2e | 99 | $this->openCiviPage("petition/add", "reset=1", "_qf_Petition_next-bottom"); |
6a488035 TO |
100 | |
101 | // fill petition tile. | |
102 | $title = substr(sha1(rand()), 0, 7); | |
103 | $this->type("title", "$title Petition"); | |
104 | ||
105 | // fill introduction | |
106 | //$this->type("cke_instructions", "This is introduction of $title Petition"); | |
107 | ||
108 | // select campaign | |
109 | $this->select("campaign_id", "value=1"); | |
110 | ||
111 | // select profile | |
112 | $this->select("contact_profile_id", "value=4"); | |
113 | ||
114 | // click save | |
d226f7d8 | 115 | $this->clickLink('_qf_Petition_next-bottom'); |
6a488035 | 116 | |
d226f7d8 | 117 | $this->waitForText('crm-notification-container', "Petition has been saved."); |
6a488035 TO |
118 | |
119 | $this->waitForElementPresent("link=Add Petition"); | |
fe725ccb | 120 | $this->waitForElementPresent("search_form_petition"); |
6a488035 TO |
121 | $this->click("search_form_petition"); |
122 | $this->type("petition_title", $title); | |
123 | ||
124 | $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']"); | |
a488ca1a | 125 | $this->waitForElementPresent("xpath=//div[@id='petitionList']/div/table/tbody//tr//td[@class=' crm-petition-action']//span[text()='more']/ul//li/a[text()='Sign']"); |
126 | $url = $this->getAttribute("xpath=//div[@id='petitionList']/div/table/tbody//tr//td[@class=' crm-petition-action']//span[text()='more']/ul//li/a[text()='Sign']@href"); | |
6a488035 TO |
127 | |
128 | ////////////// Retrieve Sign Petition Url ///////////////////////// | |
129 | ||
130 | // logout and sign as anonymous. | |
42daf119 | 131 | $this->webtestLogout(); |
6a488035 TO |
132 | |
133 | // go to the link that you will be sign as anonymous | |
134 | $this->open($url); | |
135 | $this->waitForElementPresent("_qf_Signature_next-bottom"); | |
136 | ||
137 | // fill first name | |
138 | $firstName = substr(sha1(rand()), 0, 7); | |
139 | $this->type("first_name", $firstName); | |
140 | ||
141 | // fill last name | |
142 | $lastName = substr(sha1(rand()), 0, 7); | |
143 | $this->type("last_name", $lastName); | |
144 | ||
145 | // fill email | |
146 | $email = $firstName . "@" . $lastName . ".com"; | |
147 | $this->type("email-Primary", $email); | |
148 | ||
149 | // click Sign the petition. | |
d226f7d8 RN |
150 | $this->clickLink('_qf_Signature_next-bottom', NULL); |
151 | $this->waitForText('page-title', "Thank You"); | |
6a488035 TO |
152 | |
153 | // login | |
6a488035 TO |
154 | $this->webtestLogin(); |
155 | ||
42daf119 | 156 | $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition"); |
6a488035 TO |
157 | |
158 | // check for unconfirmed petition signature | |
fe725ccb | 159 | $this->waitForElementPresent("search_form_petition"); |
6a488035 TO |
160 | $this->click("search_form_petition"); |
161 | $this->type("petition_title", $title); | |
162 | $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']"); | |
163 | ||
f78f9745 RK |
164 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']"); |
165 | $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[3]/a[text()='Signatures']"); | |
6a488035 TO |
166 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
167 | ||
168 | // verify tabular data | |
169 | $expected = array( | |
170 | 2 => 'Petition', | |
171 | 3 => "$title Petition", | |
814588fc | 172 | 4 => "$lastName, $firstName", |
6a488035 TO |
173 | 5 => "$lastName, $firstName", |
174 | 8 => 'Scheduled', | |
175 | ); | |
176 | ||
177 | foreach ($expected as $column => $value) { | |
642aa483 | 178 | $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[$column]/", preg_quote($value)); |
6a488035 | 179 | } |
76e86fd8 | 180 | |
6a488035 | 181 | // ONCE MORE, NO EMAIL VERIFICATION AND CUSTOM THANK-YOU |
071a6d2e | 182 | $this->openCiviPage("petition/add", "reset=1", "_qf_Petition_next-bottom"); |
6a488035 TO |
183 | |
184 | // fill petition tile. | |
185 | $title = substr(sha1(rand()), 0, 7); | |
186 | $this->type("title", "$title Petition"); | |
187 | ||
188 | // fill introduction | |
189 | //$this->type("cke_instructions", "This is introduction of $title Petition"); | |
190 | ||
191 | // select campaign | |
192 | $this->select("campaign_id", "value=1"); | |
193 | ||
194 | // select profile | |
195 | $this->select("contact_profile_id", "value=4"); | |
196 | ||
197 | // bypass email confirmation | |
198 | $this->click("bypass_confirm"); | |
199 | ||
200 | // set custom thank-you title and text | |
201 | $this->type('thankyou_title', "Awesome $title donation"); | |
202 | $this->fillRichTextField('thankyou_text', "Thank you for your kind contribution to support $title", 'CKEditor'); | |
203 | ||
204 | // click save | |
d226f7d8 | 205 | $this->clickLink('_qf_Petition_next-bottom'); |
6a488035 | 206 | |
d226f7d8 | 207 | $this->waitForText('crm-notification-container', "Petition has been saved."); |
6a488035 TO |
208 | |
209 | $this->waitForElementPresent("link=Add Petition"); | |
210 | ||
fe725ccb | 211 | $this->waitForElementPresent("search_form_petition"); |
6a488035 TO |
212 | $this->click("search_form_petition"); |
213 | $this->type("petition_title", $title); | |
214 | ||
215 | $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']"); | |
216 | ||
fe725ccb RK |
217 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']"); |
218 | $url = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']@href"); | |
6a488035 TO |
219 | |
220 | // logout and sign as anonymous. | |
42daf119 | 221 | $this->webtestLogout(); |
6a488035 TO |
222 | |
223 | // go to the link that you will be sign as anonymous | |
224 | $this->open($url); | |
225 | $this->waitForElementPresent("_qf_Signature_next-bottom"); | |
226 | ||
227 | // fill first name | |
228 | $firstName = substr(sha1(rand()), 0, 7); | |
229 | $this->type("first_name", $firstName); | |
230 | ||
231 | // fill last name | |
232 | $lastName = substr(sha1(rand()), 0, 7); | |
233 | $this->type("last_name", $lastName); | |
234 | ||
235 | // fill email | |
236 | $email = $firstName . "@" . $lastName . ".com"; | |
237 | $this->type("email-Primary", $email); | |
238 | ||
239 | // click Sign the petition. | |
d226f7d8 | 240 | $this->clickLink('_qf_Signature_next-bottom', 'thankyou_text'); |
76e86fd8 | 241 | |
6a488035 | 242 | // check that thank-you page has appropriate title and message |
d226f7d8 RN |
243 | $this->waitForText('page-title', "Awesome $title donation"); |
244 | $this->waitForText('thankyou_text', "Thank you for your kind contribution to support $title"); | |
6a488035 TO |
245 | |
246 | // login | |
6a488035 TO |
247 | $this->webtestLogin(); |
248 | ||
42daf119 | 249 | $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition"); |
6a488035 TO |
250 | |
251 | // check for confirmed petition signature | |
fe725ccb | 252 | $this->waitForElementPresent("search_form_petition"); |
6a488035 TO |
253 | $this->click("search_form_petition"); |
254 | $this->type("petition_title", $title); | |
255 | $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']"); | |
256 | ||
ff6ef696 | 257 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']"); |
d25d8bbf | 258 | $this->click("xpath=//table[@class='petitions dataTable no-footer']/tbody/tr/td[10]/span[2][text()='more']/ul/li[3]/a[text()='Signatures']"); |
6a488035 TO |
259 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
260 | ||
261 | // verify tabular data | |
262 | $expected = array( | |
263 | 2 => 'Petition', | |
264 | 3 => "$title Petition", | |
814588fc | 265 | 4 => "$lastName, $firstName", |
6a488035 TO |
266 | 5 => "$lastName, $firstName", |
267 | 8 => 'Completed', | |
268 | ); | |
269 | ||
270 | foreach ($expected as $column => $value) { | |
642aa483 | 271 | $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[$column]/", preg_quote($value)); |
3fb27458 | 272 | } |
6a488035 | 273 | } |
96025800 | 274 | |
6a488035 | 275 | } |