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_Campaign_PetitionUsageScenarioTest
32 class WebTest_Campaign_PetitionUsageScenarioTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testPetitionUsageScenario() {
39 $this->markTestSkipped('Skipping for now as it works fine locally.');
40 $this->webtestLogin('admin');
42 // Enable CiviCampaign module if necessary
43 $this->enableComponents("CiviCampaign");
45 // handle permissions early
47 // let's give permission 'sign CiviCRM Petition' to anonymous user.
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",
64 $this->changePermissions($permissions);
66 // Log in as normal user
67 $this->webtestLogin();
69 /////////////// Create Campaign ///////////////////////////////
71 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
73 $title = substr(sha1(rand()), 0, 7);
74 $this->type("title", "$title Campaign");
76 // select the campaign type
77 $this->select("campaign_type_id", "value=2");
79 // fill in the description
80 $this->type("description", "This is a test campaign");
82 // include groups for the campaign
83 $this->addSelection("includeGroups", "label=Advisory Board");
84 $this->click("//option[@value=4]");
86 // fill the end date for campaign
87 $this->webtestFillDate("end_date", "+1 year");
89 // select campaign status
90 $this->select("status_id", "value=2");
93 $this->clickLink('_qf_Campaign_upload-bottom');
95 $this->waitForText('crm-notification-container', "Campaign $title Campaign has been saved.");
97 ////////////// Create petition using New Individual profile //////////////////////
99 $this->openCiviPage("petition/add", "reset=1", "_qf_Petition_next-bottom");
101 // fill petition tile.
102 $title = substr(sha1(rand()), 0, 7);
103 $this->type("title", "$title Petition");
106 //$this->type("cke_instructions", "This is introduction of $title Petition");
109 $this->select("campaign_id", "value=1");
112 $this->select("contact_profile_id", "value=4");
115 $this->clickLink('_qf_Petition_next-bottom');
117 $this->waitForText('crm-notification-container', "Petition has been saved.");
119 $this->waitForElementPresent("link=Add Petition");
120 $this->waitForElementPresent("search_form_petition");
121 $this->click("search_form_petition");
122 $this->type("petition_title", $title);
124 $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
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");
128 ////////////// Retrieve Sign Petition Url /////////////////////////
130 // logout and sign as anonymous.
131 $this->webtestLogout();
133 // go to the link that you will be sign as anonymous
135 $this->waitForElementPresent("_qf_Signature_next-bottom");
138 $firstName = substr(sha1(rand()), 0, 7);
139 $this->type("first_name", $firstName);
142 $lastName = substr(sha1(rand()), 0, 7);
143 $this->type("last_name", $lastName);
146 $email = $firstName . "@" . $lastName . ".com";
147 $this->type("email-Primary", $email);
149 // click Sign the petition.
150 $this->clickLink('_qf_Signature_next-bottom', NULL);
151 $this->waitForText('page-title', "Thank You");
154 $this->webtestLogin();
156 $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition");
158 // check for unconfirmed petition signature
159 $this->waitForElementPresent("search_form_petition");
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']");
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']");
166 $this->waitForPageToLoad($this->getTimeoutMsec());
168 // verify tabular data
171 3 => "$title Petition",
172 4 => "$lastName, $firstName",
173 5 => "$lastName, $firstName",
177 foreach ($expected as $column => $value) {
178 $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[$column]/", preg_quote($value));
181 // ONCE MORE, NO EMAIL VERIFICATION AND CUSTOM THANK-YOU
182 $this->openCiviPage("petition/add", "reset=1", "_qf_Petition_next-bottom");
184 // fill petition tile.
185 $title = substr(sha1(rand()), 0, 7);
186 $this->type("title", "$title Petition");
189 //$this->type("cke_instructions", "This is introduction of $title Petition");
192 $this->select("campaign_id", "value=1");
195 $this->select("contact_profile_id", "value=4");
197 // bypass email confirmation
198 $this->click("bypass_confirm");
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');
205 $this->clickLink('_qf_Petition_next-bottom');
207 $this->waitForText('crm-notification-container', "Petition has been saved.");
209 $this->waitForElementPresent("link=Add Petition");
211 $this->waitForElementPresent("search_form_petition");
212 $this->click("search_form_petition");
213 $this->type("petition_title", $title);
215 $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
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");
220 // logout and sign as anonymous.
221 $this->webtestLogout();
223 // go to the link that you will be sign as anonymous
225 $this->waitForElementPresent("_qf_Signature_next-bottom");
228 $firstName = substr(sha1(rand()), 0, 7);
229 $this->type("first_name", $firstName);
232 $lastName = substr(sha1(rand()), 0, 7);
233 $this->type("last_name", $lastName);
236 $email = $firstName . "@" . $lastName . ".com";
237 $this->type("email-Primary", $email);
239 // click Sign the petition.
240 $this->clickLink('_qf_Signature_next-bottom', 'thankyou_text');
242 // check that thank-you page has appropriate title and message
243 $this->waitForText('page-title', "Awesome $title donation");
244 $this->waitForText('thankyou_text', "Thank you for your kind contribution to support $title");
247 $this->webtestLogin();
249 $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition");
251 // check for confirmed petition signature
252 $this->waitForElementPresent("search_form_petition");
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']");
257 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']");
258 $this->click("xpath=//table[@class='petitions dataTable no-footer']/tbody/tr/td[10]/span[2][text()='more']/ul/li[3]/a[text()='Signatures']");
259 $this->waitForPageToLoad($this->getTimeoutMsec());
261 // verify tabular data
264 3 => "$title Petition",
265 4 => "$lastName, $firstName",
266 5 => "$lastName, $firstName",
270 foreach ($expected as $column => $value) {
271 $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[$column]/", preg_quote($value));