X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FEvent%2FPricesetMaxCountTest.php;h=1f1b38dcc2c2ca8cca461f6009a4f7cc8033cf37;hb=10525e4437a80b3f750037373d57a56888c45d82;hp=9e81951942306bf11f2495a0c71274ae91f27b88;hpb=c3ad86334b83050ce3869a4b00925280ca50e4a2;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php index 9e81951942..1f1b38dcc2 100644 --- a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php +++ b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php @@ -1,7 +1,7 @@ webtestLogin(); @@ -117,35 +117,28 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $pricesetLoc = $this->getLocation(); // get text field Id. - $textFieldId = explode('&id=', $this->getAttribute("xpath=//div[@class='crm-main-content-wrapper']//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href")); - $textFieldId = explode('&', $textFieldId[0]); - $textFieldId = explode('=', $textFieldId[3]); - $textFieldId = $textFieldId[1]; + $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]"); + $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[9]/span[1]/a[2]@href"); + $textFieldId = $this->urlArg('fid', $textFieldIdURL); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); // get select field id $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]"); $selectFieldLoc = $this->getLocation(); - $selectFieldId = $this->urlArg('fid'); + $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href"); + $selectFieldId = $this->urlArg('fid', $selectFieldURL); // get select field ids // get select field option1 - $selectFieldOp1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href")); - $selectFieldOp1 = explode('&', $selectFieldOp1[0]); - $selectFieldOp1 = explode('=', $selectFieldOp1[2]); - $selectFieldOp1 = $selectFieldOp1[1]; - - $this->open($selectFieldLoc); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href"); + $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL); // get select field option2 - $selectFieldOp2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href")); - $selectFieldOp2 = explode('&', $selectFieldOp2[0]); - $selectFieldOp2 = explode('=', $selectFieldOp2[2]); - $selectFieldOp2 = $selectFieldOp2[1]; + $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href"); + $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); @@ -177,7 +170,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jones'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jones' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -205,7 +198,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // exceed maximun count for text field, check for form rule $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -233,7 +226,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->_checkConfirmationAndRegister(); } - function testWithFieldCount() { + public function testWithFieldCount() { // Log in using webtestLogin() method $this->webtestLogin(); @@ -322,35 +315,28 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $pricesetLoc = $this->getLocation(); // get text field Id. - $textFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href")); - $textFieldId = explode('&', $textFieldId[0]); - $textFieldId = explode('=', $textFieldId[3]); - $textFieldId = $textFieldId[1]; + $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]"); + $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href"); + $textFieldId = $this->urlArg('fid', $textFieldIdURL); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); // get select field id $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]"); $selectFieldLoc = $this->getLocation(); - $selectFieldId = $this->urlArg('fid'); + $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href"); + $selectFieldId = $this->urlArg('fid', $selectFieldURL); // get select field ids // get select field option1 - $selectFieldOp1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href")); - $selectFieldOp1 = explode('&', $selectFieldOp1[0]); - $selectFieldOp1 = explode('=', $selectFieldOp1[2]); - $selectFieldOp1 = $selectFieldOp1[1]; - - $this->open($selectFieldLoc); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href"); + $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL); // get select field option2 - $selectFieldOp2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href")); - $selectFieldOp2 = explode('&', $selectFieldOp2[0]); - $selectFieldOp2 = explode('=', $selectFieldOp2[2]); - $selectFieldOp2 = $selectFieldOp2[1]; + $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href"); + $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); @@ -380,7 +366,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -410,7 +396,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // check for form rule $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -439,7 +425,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->_checkConfirmationAndRegister(); } - function testAdditionalParticipantWithoutFieldCount() { + public function testAdditionalParticipantWithoutFieldCount() { // Log in using webtestLogin() method $this->webtestLogin(); @@ -521,35 +507,28 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $pricesetLoc = $this->getLocation(); // get text field Id. - $textFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href")); - $textFieldId = explode('&', $textFieldId[0]); - $textFieldId = explode('=', $textFieldId[3]); - $textFieldId = $textFieldId[1]; + $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]"); + $textFieldURL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[9]/span[1]/a[2]@href"); + $textFieldId = $this->urlArg('fid', $textFieldURL); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); // get select field id $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]"); $selectFieldLoc = $this->getLocation(); - $selectFieldId = $this->urlArg('fid'); + $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href"); + $selectFieldId = $this->urlArg('fid', $selectFieldURL); // get select field ids // get select field option1 - $selectFieldOp1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href")); - $selectFieldOp1 = explode('&', $selectFieldOp1[0]); - $selectFieldOp1 = explode('=', $selectFieldOp1[2]); - $selectFieldOp1 = $selectFieldOp1[1]; - - $this->open($selectFieldLoc); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[7]/span[1]/a[1]@href"); + $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL); // get select field option2 - $selectFieldOp2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href")); - $selectFieldOp2 = explode('&', $selectFieldOp2[0]); - $selectFieldOp2 = explode('=', $selectFieldOp2[2]); - $selectFieldOp2 = $selectFieldOp2[1]; + $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[2]/td[7]/span[1]/a[1]@href"); + $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); @@ -585,7 +564,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '7'); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -606,7 +585,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '6'); $this->type('first_name', 'Mary Add 2'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -627,7 +606,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); $this->type('first_name', 'Mary Add 2'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -671,7 +650,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -702,7 +681,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); $this->type('first_name', 'Mary Add 1'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -731,7 +710,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->_checkConfirmationAndRegister(); } - function testAdditionalParticipantWithFieldCount() { + public function testAdditionalParticipantWithFieldCount() { // Log in using webtestLogin() method $this->webtestLogin(); @@ -820,35 +799,28 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $pricesetLoc = $this->getLocation(); // get text field Id. - $textFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href")); - $textFieldId = explode('&', $textFieldId[0]); - $textFieldId = explode('=', $textFieldId[3]); - $textFieldId = $textFieldId[1]; + $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]"); + $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href"); + $textFieldId = $this->urlArg('fid', $textFieldIdURL); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); // get select field id $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]"); $selectFieldLoc = $this->getLocation(); - $selectFieldId = $this->urlArg('fid'); + $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href"); + $selectFieldId = $this->urlArg('fid', $selectFieldURL); // get select field ids // get select field option1 - $selectFieldOp1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href")); - $selectFieldOp1 = explode('&', $selectFieldOp1[0]); - $selectFieldOp1 = explode('=', $selectFieldOp1[2]); - $selectFieldOp1 = $selectFieldOp1[1]; - - $this->open($selectFieldLoc); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href"); + $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL); // get select field option2 - $selectFieldOp2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href")); - $selectFieldOp2 = explode('&', $selectFieldOp2[0]); - $selectFieldOp2 = explode('=', $selectFieldOp2[2]); - $selectFieldOp2 = $selectFieldOp2[1]; + $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href"); + $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); @@ -884,7 +856,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '7'); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -905,7 +877,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '6'); $this->type('first_name', 'Mary Add 1'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -926,7 +898,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); $this->type('first_name', 'Mary Add 2'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -970,7 +942,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); $this->type('first_name', 'Mary'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -1001,7 +973,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); $this->type('first_name', 'Mary Add 1'); - $this->type('last_name', 'Jane'. substr(sha1(rand()), 0, 5)); + $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5)); $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; $this->type('email-Primary', $email); @@ -1034,7 +1006,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { * @param $setTitle * @param null $financialType */ - function _testAddSet($setTitle, $financialType = NULL) { + public function _testAddSet($setTitle, $financialType = NULL) { $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom'); // Enter Priceset fields (Title, Used For ...) @@ -1055,11 +1027,12 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { /** * @param $fields */ - function _testAddPriceFields($fields) { + public function _testAddPriceFields($fields) { $fieldCount = count($fields); $count = 1; $this->waitForElementPresent('label'); foreach ($fields as $label => $field) { + $this->waitForElementPresent('label'); $this->type('label', $label); $this->select('html_type', "value={$field['type']}"); @@ -1101,6 +1074,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { else { $this->click('_qf_Field_next-bottom'); } + $this->waitForAjaxContent(); $this->waitForText('crm-notification-container', "Price Field '$label' has been saved."); $count++; @@ -1111,7 +1085,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { * @param $options * @param $fieldType */ - function _testAddMultipleChoiceOptions($options, $fieldType) { + public function _testAddMultipleChoiceOptions($options, $fieldType) { foreach ($options as $oIndex => $oValue) { $this->type("option_label_{$oIndex}", $oValue['label']); $this->type("option_amount_{$oIndex}", $oValue['amount']); @@ -1143,11 +1117,11 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { } /** - * @param $params + * @param array $params * * @return string */ - function _testAddEvent($params) { + public function _testAddEvent($params) { $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); $this->select('event_type_id', "value={$params['event_type_id']}"); @@ -1225,7 +1199,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { return $this->getLocation(); } - function _fillRegisterWithBillingInfo() { + public function _fillRegisterWithBillingInfo() { $this->waitForElementPresent('credit_card_type'); $this->select('credit_card_type', 'value=Visa'); $this->type('credit_card_number', '4111111111111111'); @@ -1244,7 +1218,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); } - function _checkConfirmationAndRegister() { + public function _checkConfirmationAndRegister() { $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information'); $this->assertStringsPresent($confirmStrings); $this->click('_qf_Confirm_next-bottom');