| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 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 | +--------------------------------------------------------------------+ |
| 25 | */ |
| 26 | |
| 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
| 28 | |
| 29 | /** |
| 30 | * Class WebTest_Contribute_OnlineContributionTest |
| 31 | */ |
| 32 | class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase { |
| 33 | |
| 34 | protected function setUp() { |
| 35 | parent::setUp(); |
| 36 | } |
| 37 | |
| 38 | public function testOnlineContributionAdd() { |
| 39 | $this->webtestLogin(); |
| 40 | |
| 41 | // Use default payment processor |
| 42 | $processorName = 'Test Processor'; |
| 43 | $processorType = 'Dummy'; |
| 44 | $pageTitle = substr(sha1(rand()), 0, 7); |
| 45 | $rand = 2 * rand(10, 50); |
| 46 | $hash = substr(sha1(rand()), 0, 7); |
| 47 | $amountSection = TRUE; |
| 48 | $payLater = FALSE; |
| 49 | $onBehalf = FALSE; |
| 50 | $pledges = FALSE; |
| 51 | $recurring = FALSE; |
| 52 | $memberships = FALSE; |
| 53 | $friend = TRUE; |
| 54 | $profilePreId = 1; |
| 55 | $profilePostId = NULL; |
| 56 | $premiums = FALSE; |
| 57 | $widget = FALSE; |
| 58 | $pcp = FALSE; |
| 59 | $memPriceSetId = NULL; |
| 60 | |
| 61 | // create a new online contribution page |
| 62 | // create contribution page with randomized title and default params |
| 63 | $pageId = $this->webtestAddContributionPage($hash, |
| 64 | $rand, |
| 65 | $pageTitle, |
| 66 | array($processorName => $processorType), |
| 67 | $amountSection, |
| 68 | $payLater, |
| 69 | $onBehalf, |
| 70 | $pledges, |
| 71 | $recurring, |
| 72 | $memberships, |
| 73 | $memPriceSetId, |
| 74 | $friend, |
| 75 | $profilePreId, |
| 76 | $profilePostId, |
| 77 | $premiums, |
| 78 | $widget, |
| 79 | $pcp |
| 80 | ); |
| 81 | |
| 82 | //logout |
| 83 | $this->webtestLogout(); |
| 84 | |
| 85 | //Open Live Contribution Page |
| 86 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom"); |
| 87 | |
| 88 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); |
| 89 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
| 90 | $honorFirstName = 'In' . substr(sha1(rand()), 0, 4); |
| 91 | $honorLastName = 'Hon' . substr(sha1(rand()), 0, 7); |
| 92 | $honorEmail = $honorFirstName . "@example.com"; |
| 93 | $honorSortName = $honorLastName . ', ' . $honorFirstName; |
| 94 | $honorDisplayName = 'Ms. ' . $honorFirstName . ' ' . $honorLastName; |
| 95 | |
| 96 | $this->type("email-5", $firstName . "@example.com"); |
| 97 | |
| 98 | $this->type("first_name", $firstName); |
| 99 | $this->type("last_name", $lastName); |
| 100 | |
| 101 | $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input"); |
| 102 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100); |
| 103 | |
| 104 | $streetAddress = "100 Main Street"; |
| 105 | $this->type("street_address-1", $streetAddress); |
| 106 | $this->type("city-1", "San Francisco"); |
| 107 | $this->type("postal_code-1", "94117"); |
| 108 | $this->select("country-1", "value=1228"); |
| 109 | $this->select("state_province-1", "value=1001"); |
| 110 | // Honoree Info |
| 111 | $this->click("xpath=id('Main')/div[3]/fieldset/div[2]/div/label[text()='In Honor of']"); |
| 112 | |
| 113 | $this->select("honor[prefix_id]", "label=Ms."); |
| 114 | $this->type("honor[first_name]", $honorFirstName); |
| 115 | $this->type("honor[last_name]", $honorLastName); |
| 116 | $this->type("honor[email-1]", $honorEmail); |
| 117 | |
| 118 | //Credit Card Info |
| 119 | $this->select("credit_card_type", "value=Visa"); |
| 120 | $this->type("credit_card_number", "4111111111111111"); |
| 121 | $this->type("cvv2", "000"); |
| 122 | $this->select("credit_card_exp_date[M]", "value=1"); |
| 123 | $this->select("credit_card_exp_date[Y]", "value=2020"); |
| 124 | |
| 125 | //Billing Info |
| 126 | $this->type("billing_first_name", $firstName . "billing"); |
| 127 | $this->type("billing_last_name", $lastName . "billing"); |
| 128 | $this->type("billing_street_address-5", "15 Main St."); |
| 129 | $this->type(" billing_city-5", "San Jose"); |
| 130 | $this->select("billing_country_id-5", "value=1228"); |
| 131 | $this->select("billing_state_province_id-5", "value=1004"); |
| 132 | $this->type("billing_postal_code-5", "94129"); |
| 133 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
| 134 | |
| 135 | $this->click("_qf_Confirm_next-bottom"); |
| 136 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 137 | |
| 138 | //login to check contribution |
| 139 | |
| 140 | // Log in using webtestLogin() method |
| 141 | $this->webtestLogin(); |
| 142 | |
| 143 | //Find Contribution |
| 144 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); |
| 145 | $this->type("sort_name", "$lastName $firstName"); |
| 146 | $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]"); |
| 147 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 148 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); |
| 149 | |
| 150 | //View Contribution Record and verify data |
| 151 | $expected = array( |
| 152 | 'From' => "{$firstName} {$lastName}", |
| 153 | 'Financial Type' => 'Donation', |
| 154 | 'Total Amount' => '100.00', |
| 155 | 'Contribution Status' => 'Completed', |
| 156 | ); |
| 157 | $this->webtestVerifyTabularData($expected); |
| 158 | //View Soft Credit record of type 'Honor of' |
| 159 | $this->waitForTextPresent($honorDisplayName); |
| 160 | $this->waitForTextPresent('100.00 (In Honor of)'); |
| 161 | |
| 162 | // Check for Honoree contact created |
| 163 | $this->click("css=input#sort_name_navigation"); |
| 164 | $this->type("css=input#sort_name_navigation", $honorSortName); |
| 165 | $this->typeKeys("css=input#sort_name_navigation", $honorSortName); |
| 166 | |
| 167 | // wait for result list |
| 168 | $this->waitForElementPresent("css=ul.ui-autocomplete li"); |
| 169 | |
| 170 | // visit contact summary page |
| 171 | $this->click("css=ul.ui-autocomplete li"); |
| 172 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 173 | |
| 174 | // Is contact present? |
| 175 | $this->assertTrue($this->isTextPresent("$honorDisplayName"), "Honoree contact not found."); |
| 176 | |
| 177 | // CRM-16064 - Contributions pricesets charge $1 more than selected |
| 178 | $contributionAmt = number_format($rand, 2); |
| 179 | $label = "Label $hash"; |
| 180 | $this->_verifyContributionAmt($pageId, $contributionAmt, $label); |
| 181 | |
| 182 | } |
| 183 | |
| 184 | public function testOnlineContributionWithZeroAmount() { |
| 185 | $this->webtestLogin(); |
| 186 | |
| 187 | // Use default payment processor |
| 188 | $processorName = 'Test Processor'; |
| 189 | $processorType = 'Dummy'; |
| 190 | $pageTitle = substr(sha1(rand()), 0, 7); |
| 191 | $rand = 2 * rand(10, 50); |
| 192 | $hash = substr(sha1(rand()), 0, 7); |
| 193 | $amountSection = TRUE; |
| 194 | $payLater = FALSE; |
| 195 | $onBehalf = FALSE; |
| 196 | $pledges = FALSE; |
| 197 | $recurring = FALSE; |
| 198 | $memberships = FALSE; |
| 199 | $friend = FALSE; |
| 200 | $profilePreId = NULL; |
| 201 | $profilePostId = NULL; |
| 202 | $premiums = FALSE; |
| 203 | $widget = FALSE; |
| 204 | $pcp = FALSE; |
| 205 | $memPriceSetId = NULL; |
| 206 | |
| 207 | // create a new online contribution page |
| 208 | // create contribution page with randomized title and default params |
| 209 | $pageId = $this->webtestAddContributionPage($hash, |
| 210 | $rand, |
| 211 | $pageTitle, |
| 212 | array($processorName => $processorType), |
| 213 | $amountSection, |
| 214 | $payLater, |
| 215 | $onBehalf, |
| 216 | $pledges, |
| 217 | $recurring, |
| 218 | $memberships, |
| 219 | $memPriceSetId, |
| 220 | $friend, |
| 221 | $profilePreId, |
| 222 | $profilePostId, |
| 223 | $premiums, |
| 224 | $widget, |
| 225 | $pcp |
| 226 | ); |
| 227 | |
| 228 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_cancel-bottom'); |
| 229 | $this->type('label_1', "Label $hash"); |
| 230 | $this->type('value_1', 0); |
| 231 | $this->clickLink('_qf_Amount_upload_done-top'); |
| 232 | |
| 233 | //Contribution using Contribution Options |
| 234 | $this->_doContributionAndVerifyData($pageId); |
| 235 | |
| 236 | //add priceset |
| 237 | $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom'); |
| 238 | $this->type('title', "Test Priceset $rand"); |
| 239 | $this->check('extends_2'); |
| 240 | $this->select("financial_type_id", "label=Donation"); |
| 241 | $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom', FALSE); |
| 242 | $sid = $this->urlArg('sid'); |
| 243 | //add field |
| 244 | $this->type('label', "Testfield"); |
| 245 | $this->select('html_type', "value=Radio"); |
| 246 | $this->type('option_label_1', 'test Label'); |
| 247 | $this->type('option_amount_1', 0.00); |
| 248 | $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE); |
| 249 | $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_cancel-bottom'); |
| 250 | $this->select('price_set_id', "value=$sid"); |
| 251 | $this->clickLink('_qf_Amount_upload_done-bottom', FALSE); |
| 252 | |
| 253 | //Contribution using priceset |
| 254 | $this->_doContributionAndVerifyData($pageId, TRUE); |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * @param int $pageId |
| 259 | * @param bool $priceSet |
| 260 | */ |
| 261 | public function _doContributionAndVerifyData($pageId, $priceSet = FALSE) { |
| 262 | //logout |
| 263 | $this->webtestLogout(); |
| 264 | $amountLabel = 'Total Amount'; |
| 265 | $amountValue = '0.00'; |
| 266 | //Open Live Contribution Page |
| 267 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom"); |
| 268 | |
| 269 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); |
| 270 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
| 271 | $email = $firstName . "@example.com"; |
| 272 | $this->type("email-5", $email); |
| 273 | |
| 274 | if ($priceSet) { |
| 275 | $this->click("xpath=//div[@id='priceset']/div/div[2]/div/span/input"); |
| 276 | $amountLabel = 'Contribution Amount'; |
| 277 | $amountValue = 'Contribution Total: $ 0.00'; |
| 278 | } |
| 279 | |
| 280 | //Credit Card Info |
| 281 | $this->select("credit_card_type", "value=Visa"); |
| 282 | $this->type("credit_card_number", "4111111111111111"); |
| 283 | $this->type("cvv2", "000"); |
| 284 | $this->select("credit_card_exp_date[M]", "value=1"); |
| 285 | $this->select("credit_card_exp_date[Y]", "value=2020"); |
| 286 | |
| 287 | //Billing Info |
| 288 | $this->type("billing_first_name", $firstName); |
| 289 | $this->type("billing_last_name", $lastName); |
| 290 | $this->type("billing_street_address-5", "15 Main St."); |
| 291 | $this->type(" billing_city-5", "San Jose"); |
| 292 | $this->select("billing_country_id-5", "value=1228"); |
| 293 | $this->select("billing_state_province_id-5", "value=1004"); |
| 294 | $this->type("billing_postal_code-5", "94129"); |
| 295 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
| 296 | |
| 297 | $this->clickLink("_qf_Confirm_next-bottom", NULL); |
| 298 | |
| 299 | //login to check contribution |
| 300 | |
| 301 | // Log in using webtestLogin() method |
| 302 | $this->webtestLogin(); |
| 303 | |
| 304 | //Find Contribution |
| 305 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); |
| 306 | $this->type("sort_name", "$email"); |
| 307 | $this->waitForAjaxContent(); |
| 308 | $this->click("xpath=//div[@class='crm-accordion-wrapper crm-contribution_search_form-accordion ']/div[2]/table/tbody/tr[8]/td[1]/table/tbody/tr[3]/td[2]/label[1]"); |
| 309 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", FALSE); |
| 310 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); |
| 311 | |
| 312 | //View Contribution Record and verify data |
| 313 | $expected = array( |
| 314 | 'From' => "{$email}", |
| 315 | 'Financial Type' => 'Donation', |
| 316 | $amountLabel => $amountValue, |
| 317 | 'Contribution Status' => 'Completed', |
| 318 | ); |
| 319 | $this->webtestVerifyTabularData($expected); |
| 320 | } |
| 321 | |
| 322 | public function _verifyContributionAmt($pageId, $contributionAmt, $label) { |
| 323 | // logout |
| 324 | $this->webtestLogout(); |
| 325 | |
| 326 | //Open Live Contribution Page |
| 327 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom"); |
| 328 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); |
| 329 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
| 330 | $this->type("email-5", $firstName . "@example.com"); |
| 331 | |
| 332 | $this->type("first_name", $firstName); |
| 333 | $this->type("last_name", $lastName); |
| 334 | $this->check("xpath=//div[@id='priceset']/div[contains(@class, 'contribution_amount-section')]//div[contains(@class, 'contribution_amount-row1')]/span/input"); |
| 335 | $streetAddress = "100 Main Street"; |
| 336 | $this->type("street_address-1", $streetAddress); |
| 337 | $this->type("city-1", "San Francisco"); |
| 338 | $this->type("postal_code-1", "94117"); |
| 339 | $this->select("country-1", "value=1228"); |
| 340 | $this->select("state_province-1", "value=1001"); |
| 341 | |
| 342 | //Credit Card Info |
| 343 | $this->select("credit_card_type", "value=Visa"); |
| 344 | $this->type("credit_card_number", "4111111111111111"); |
| 345 | $this->type("cvv2", "000"); |
| 346 | $this->select("credit_card_exp_date[M]", "value=1"); |
| 347 | $this->select("credit_card_exp_date[Y]", "value=2020"); |
| 348 | |
| 349 | //Billing Info |
| 350 | $this->type("billing_first_name", $firstName . "billing"); |
| 351 | $this->type("billing_last_name", $lastName . "billing"); |
| 352 | $this->type("billing_street_address-5", "15 Main St."); |
| 353 | $this->type(" billing_city-5", "San Jose"); |
| 354 | $this->select("billing_country_id-5", "value=1228"); |
| 355 | $this->select("billing_state_province_id-5", "value=1004"); |
| 356 | $this->type("billing_postal_code-5", "94129"); |
| 357 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
| 358 | |
| 359 | $this->assertElementContainsText("xpath=//div[contains(@class, 'amount_display-group')]//div[@class='display-block']/strong", "$ $contributionAmt - $label", "Contribution amount does not match"); |
| 360 | $this->clickLink("_qf_Confirm_next-bottom"); |
| 361 | $this->assertElementContainsText("xpath=//div[contains(@class, 'amount_display-group')]//div[@class='display-block']/strong", "$ $contributionAmt - $label", "Contribution amount does not match"); |
| 362 | // Log in using webtestLogin() method |
| 363 | $this->webtestLogin(); |
| 364 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); |
| 365 | |
| 366 | $this->type("sort_name", "$lastName $firstName"); |
| 367 | $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]"); |
| 368 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
| 369 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); |
| 370 | |
| 371 | //View Contribution Record and verify data |
| 372 | $expected = array( |
| 373 | 'From' => "{$firstName} {$lastName}", |
| 374 | 'Financial Type' => 'Donation', |
| 375 | 'Total Amount' => $contributionAmt, |
| 376 | 'Contribution Status' => 'Completed', |
| 377 | ); |
| 378 | $this->webtestVerifyTabularData($expected); |
| 379 | } |
| 380 | |
| 381 | public function testOnlineContributionWithPremium() { |
| 382 | //CRM-16713: Contribution search by premiums on find contribution form. |
| 383 | $this->webtestLogin(); |
| 384 | |
| 385 | // Use default payment processor |
| 386 | $processorName = 'Test Processor'; |
| 387 | $processorType = 'Dummy'; |
| 388 | $pageTitle = substr(sha1(rand()), 0, 7); |
| 389 | $rand = 2 * rand(10, 50); |
| 390 | $hash = substr(sha1(rand()), 0, 7); |
| 391 | $amountSection = TRUE; |
| 392 | $payLater = FALSE; |
| 393 | $onBehalf = FALSE; |
| 394 | $pledges = FALSE; |
| 395 | $recurring = FALSE; |
| 396 | $memberships = FALSE; |
| 397 | $friend = TRUE; |
| 398 | $profilePreId = 1; |
| 399 | $profilePostId = NULL; |
| 400 | $premiums = TRUE; |
| 401 | $widget = FALSE; |
| 402 | $pcp = FALSE; |
| 403 | $memPriceSetId = NULL; |
| 404 | |
| 405 | // create a new online contribution page |
| 406 | // create contribution page with randomized title and default params |
| 407 | $pageId = $this->webtestAddContributionPage($hash, |
| 408 | $rand, |
| 409 | $pageTitle, |
| 410 | array($processorName => $processorType), |
| 411 | $amountSection, |
| 412 | $payLater, |
| 413 | $onBehalf, |
| 414 | $pledges, |
| 415 | $recurring, |
| 416 | $memberships, |
| 417 | $memPriceSetId, |
| 418 | $friend, |
| 419 | $profilePreId, |
| 420 | $profilePostId, |
| 421 | $premiums, |
| 422 | $widget, |
| 423 | $pcp |
| 424 | ); |
| 425 | |
| 426 | //logout |
| 427 | $this->webtestLogout(); |
| 428 | |
| 429 | //Open Live Contribution Page |
| 430 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom"); |
| 431 | |
| 432 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); |
| 433 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
| 434 | |
| 435 | $this->type("email-5", $firstName . "@example.com"); |
| 436 | |
| 437 | $this->waitForAjaxContent(); |
| 438 | $this->click("xpath=//div[@id='premiums-listings']/div[2]/div[1]"); |
| 439 | $this->waitForAjaxContent(); |
| 440 | $this->select("xpath=//div[@id='premiums']/fieldset/div[@id='premiums-listings']/div[2]/div[2]/div[2]/div[4]/p/select", "value=Black"); |
| 441 | |
| 442 | $this->type("first_name", $firstName); |
| 443 | $this->type("last_name", $lastName); |
| 444 | |
| 445 | $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input"); |
| 446 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100); |
| 447 | |
| 448 | $streetAddress = "100 Main Street"; |
| 449 | $this->type("street_address-1", $streetAddress); |
| 450 | $this->type("city-1", "San Francisco"); |
| 451 | $this->type("postal_code-1", "94117"); |
| 452 | $this->select("country-1", "value=1228"); |
| 453 | $this->select("state_province-1", "value=1001"); |
| 454 | |
| 455 | //Credit Card Info |
| 456 | $this->select("credit_card_type", "value=Visa"); |
| 457 | $this->type("credit_card_number", "4111111111111111"); |
| 458 | $this->type("cvv2", "000"); |
| 459 | $this->select("credit_card_exp_date[M]", "value=1"); |
| 460 | $this->select("credit_card_exp_date[Y]", "value=2020"); |
| 461 | |
| 462 | //Billing Info |
| 463 | $this->type("billing_first_name", $firstName . "billing"); |
| 464 | $this->type("billing_last_name", $lastName . "billing"); |
| 465 | $this->type("billing_street_address-5", "15 Main St."); |
| 466 | $this->type(" billing_city-5", "San Jose"); |
| 467 | $this->select("billing_country_id-5", "value=1228"); |
| 468 | $this->select("billing_state_province_id-5", "value=1004"); |
| 469 | $this->type("billing_postal_code-5", "94129"); |
| 470 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
| 471 | |
| 472 | $this->click("_qf_Confirm_next-bottom"); |
| 473 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 474 | |
| 475 | // Log in using webtestLogin() method |
| 476 | $this->webtestLogin(); |
| 477 | |
| 478 | //Find Contribution |
| 479 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); |
| 480 | $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]"); |
| 481 | $this->type("sort_name", "$lastName $firstName"); |
| 482 | $this->multiselect2('contribution_product_id', array('Coffee Mug')); |
| 483 | $this->click("_qf_Search_refresh"); |
| 484 | $this->waitForElementPresent("xpath=//div[@id='contributionSearch']/table/tbody//tr/td[11]/span/a[text()='View']"); |
| 485 | $this->click("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]/td[3]/a[text()='{$lastName}, {$firstName}']/../../td[11]/span/a[text()='View']"); |
| 486 | $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]"); |
| 487 | |
| 488 | //View Contribution Record and verify data |
| 489 | $expected = array( |
| 490 | 'From' => "{$firstName} {$lastName}", |
| 491 | 'Financial Type' => 'Donation', |
| 492 | 'Total Amount' => '100.00', |
| 493 | 'Contribution Status' => 'Completed', |
| 494 | 'Premium' => 'Coffee Mug', |
| 495 | ); |
| 496 | $this->webtestVerifyTabularData($expected); |
| 497 | } |
| 498 | |
| 499 | } |