X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FContribute%2FAddPricesetTest.php;h=7153abc7bf8c496820eddfcc9e859649c443e411;hb=d1c1ddc7b93d4da8f297a6be49015f559df8e93d;hp=3b29dd659b5e31b1b1ce11491dc1c7edef374eab;hpb=ff7a89a128bce30ba0aae2bb7f628e7eb76e89ca;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index 3b29dd659b..7153abc7bf 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -57,7 +57,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { 'Pre-conference Meetup?' => 'Radio', 'Evening Sessions' => 'CheckBox', ); - $this->_testAddPriceFields( $fields, $validateStrings, $financialType ); + $this->_testAddPriceFields($fields, $validateStrings, $financialType); // var_dump($validateStrings); // load the Price Set Preview and check for expected values @@ -94,68 +94,71 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->select('html_type', "value={$type}"); switch ($type) { - case 'Text': - $validateStrings[] = '525.00'; - $this->type('price', '525.00'); - if ($dateSpecificFields == TRUE) { - $this->webtestFillDateTime('active_on', '+1 week'); - } - else { + case 'Text': + $validateStrings[] = '525.00'; + $this->type('price', '525.00'); + if ($dateSpecificFields == TRUE) { + $this->webtestFillDateTime('active_on', '+1 week'); + } + else { + $this->check('is_required'); + } + break; + + case 'Select': + $options = array( + 1 => array( + 'label' => 'Chicken', + 'amount' => '30.00', + ), + 2 => array( + 'label' => 'Vegetarian', + 'amount' => '25.00', + ), + ); + $this->addMultipleChoiceOptions($options, $validateStrings); + if ($dateSpecificFields == TRUE) { + $this->webtestFillDateTime('expire_on', '-1 week'); + } + break; + + case 'Radio': + $options = array( + 1 => array( + 'label' => 'Yes', + 'amount' => '50.00', + ), + 2 => array( + 'label' => 'No', + 'amount' => '0', + ), + ); + $this->addMultipleChoiceOptions($options, $validateStrings); $this->check('is_required'); - } - break; - - case 'Select': - $options = array( - 1 => array('label' => 'Chicken', - 'amount' => '30.00', - ), - 2 => array( - 'label' => 'Vegetarian', - 'amount' => '25.00', - ), - ); - $this->addMultipleChoiceOptions($options, $validateStrings); - if ($dateSpecificFields == TRUE) { - $this->webtestFillDateTime('expire_on', '-1 week'); - } - break; - - case 'Radio': - $options = array( - 1 => array('label' => 'Yes', - 'amount' => '50.00', - ), - 2 => array( - 'label' => 'No', - 'amount' => '0', - ), - ); - $this->addMultipleChoiceOptions($options, $validateStrings); - $this->check('is_required'); - if ($dateSpecificFields == TRUE) { - $this->webtestFillDateTime('active_on', '-1 week'); - } - break; - - case 'CheckBox': - $options = array( - 1 => array('label' => 'First Night', - 'amount' => '15.00', - ), - 2 => array( - 'label' => 'Second Night', - 'amount' => '15.00', - ), - ); - $this->addMultipleChoiceOptions($options, $validateStrings); - if ($dateSpecificFields == TRUE) { - $this->webtestFillDateTime('expire_on', '+1 week'); - } - break; - - default: - break; + if ($dateSpecificFields == TRUE) { + $this->webtestFillDateTime('active_on', '-1 week'); + } + break; + + case 'CheckBox': + $options = array( + 1 => array( + 'label' => 'First Night', + 'amount' => '15.00', + ), + 2 => array( + 'label' => 'Second Night', + 'amount' => '15.00', + ), + ); + $this->addMultipleChoiceOptions($options, $validateStrings); + if ($dateSpecificFields == TRUE) { + $this->webtestFillDateTime('expire_on', '+1 week'); + } + break; + + default: + break; } $this->select('financial_type_id', "label={$financialType}"); $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom'); @@ -163,58 +166,11 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { } function _testAddFinancialType() { - // Add new Financial Account - $orgName = 'Alberta '.substr(sha1(rand()), 0, 7); - $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4); - $financialAccountDescription = "{$financialAccountTitle} Description"; - $accountingCode = 1033; - $financialAccountType = 'Revenue'; - $taxDeductible = FALSE; - $isActive = FALSE; - $isTax = TRUE; - $taxRate = 9; - $isDefault = FALSE; - - //Add new organisation - if($orgName) { - $this->webtestAddOrganization($orgName); - } - - $this->_testAddFinancialAccount($financialAccountTitle, - $financialAccountDescription, - $accountingCode, - $orgName, - $financialAccountType, - $taxDeductible, - $isActive, - $isTax, - $taxRate, - $isDefault - ); - $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']"); - //Add new Financial Type - $financialType['name'] = 'FinancialType '.substr(sha1(rand()), 0, 4); + $financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4); $financialType['is_deductible'] = TRUE; $financialType['is_reserved'] = FALSE; $this->addeditFinancialType($financialType); - - $accountRelationship = "Income Account is"; - $expected[] = array('financial_account' => $financialAccountTitle, - - 'account_relationship' => $accountRelationship - ); - - $this->select('account_relationship', "label={$accountRelationship}"); - // Because it tends to cause problems, all uses of sleep() must be justified in comments - // Sleep should never be used for wait for anything to load from the server - // Justification for this instance: FIXME - sleep(2); - $this->select('financial_account_id', "label={$financialAccountTitle}"); - $this->click('_qf_FinancialTypeAccount_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $text = 'The financial type Account has been saved.'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); return $financialType['name']; } @@ -457,7 +413,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->webtestLogin(); //add financial type of account type expense - $financialType= $this->_testAddFinancialType(); + $financialType = $this->_testAddFinancialType(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); $usedFor = 'Contribution'; @@ -573,8 +529,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->webtestLogin(); //create a contact and return the contact id - $firstNameSoft = "John_".substr(sha1(rand()), 0, 5); - $lastNameSoft = "Doe_".substr(sha1(rand()), 0, 5); + $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5); + $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5); $this->webtestAddContact($firstNameSoft, $lastNameSoft); $url = $this->parseURL(); $cid = $url['queryString']['cid']; @@ -630,10 +586,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->type('trxn_id', 'P20901X1' . rand(100, 10000)); - $this->type('soft_credit_to', "$lastNameSoft, $firstNameSoft"); - $this->click('soft_credit_to'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); + $this->webtestFillAutocomplete("{$lastNameSoft}, {$firstNameSoft}", 'soft_credit_contact_1'); + //Additional Detail section $this->click('AdditionalDetail'); $this->waitForElementPresent('thankyou_date'); @@ -684,7 +638,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // visit contact summary page $this->click("css=div.ac_results-inner li"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->click( 'css=li#tab_contribute a' ); + $this->click('css=li#tab_contribute a'); $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)'); $id = explode('id=', $this->getAttribute("xpath=id('rowid')/td[7]/a[text()='View']@href")); @@ -694,13 +648,14 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->webtestVerifyTabularData($expected); - $params = array('contribution_id' => $id, + $params = array( + 'contribution_id' => $id, 'version' => 3, ); // Retrieve contribution from the DB via api and verify DB values against view contribution page require_once 'api/api.php'; - $fields = $this->webtest_civicrm_api('contribution','get',$params ); + $fields = $this->webtest_civicrm_api('contribution', 'get', $params); $params['id'] = $params['contact_id'] = $fields['values'][$fields['id']]['soft_credit_to']; $softCreditContact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);