Skip to content

Commit

Permalink
Merge pull request #11 from davecivicrm/CRM-11534
Browse files Browse the repository at this point in the history
Crm 11534
  • Loading branch information
kurund committed Mar 2, 2013
2 parents e39f30e + 0054ead commit 5af3d50
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 84 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,6 @@ joomla
packages/
tests/phpunit/CiviTest/civicrm.settings.local.php
l10n

vendor
civicrm.settings.php
sql/dummy_processor.mysql
2 changes: 1 addition & 1 deletion templates/CRM/Price/Form/Set.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{/if}
</td>
</tr>
<tr id="financial_type_id" class="crm-price-set-form-block-contribution_type_id crm-price-set-form-block-financial_type_id">
<tr id="financial_type_id_row" class="crm-price-set-form-block-contribution_type_id crm-price-set-form-block-financial_type_id">
<td class="label">{$form.financial_type_id.label}</td>
<td>{$form.financial_type_id.html}</td>
<td>&nbsp;</td>
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CiviTest/CiviSeleniumTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,10 @@ function webtestVerifyTabularData($expected, $xpathPrefix = NULL, $tableId = NUL
}
foreach ($expected as $label => $value) {
if ($xpathPrefix) {
$this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td", preg_quote($value));
$this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td", preg_quote($value), 'In line ' . __LINE__);
}
else {
$this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
$this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value), 'In line ' . __LINE__);
}
}
}
Expand Down
127 changes: 47 additions & 80 deletions tests/phpunit/WebTest/Contribute/AddPricesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ protected function setUp() {
}

function testAddPriceSet() {
// This is the path where our testing install resides.
// The rest of URL is defined in CiviSeleniumTestCase base class, in
// class attributes.
$this->open($this->sboxPath);

// Log in using webtestLogin() method
$this->webtestLogin();

Expand Down Expand Up @@ -86,7 +81,7 @@ function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = NULL) {
}

if ($financialType) {
$this->select("css=select.form-select", "label={$financialType}");
$this->select("financial_type_id", "label={$financialType}");
}
$this->type('help_pre', $setHelp);

Expand Down Expand Up @@ -245,11 +240,6 @@ function _testVerifyPriceSet($validateStrings, $sid) {
}

function testContributeOfflineWithPriceSet() {
// This is the path where our testing install resides.
// The rest of URL is defined in CiviSeleniumTestCase base class, in
// class attributes.
$this->open($this->sboxPath);

// Log in using webtestLogin() method
$this->webtestLogin();

Expand Down Expand Up @@ -385,7 +375,7 @@ function testContributeOnlineWithPriceSet() {

//add financial type of account type expense
$financialType = $this->_testAddFinancialType();

$setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
$usedFor = 'Contribution';
$setHelp = 'Select your conference options.';
Expand Down Expand Up @@ -452,8 +442,6 @@ function testContributeOnlineWithPriceSet() {
$lastName = 'An' . substr(sha1(rand()), 0, 7);
$this->waitForElementPresent('_qf_Main_upload-bottom');
$this->type('email-5', $firstName . '@example.com');
$this->type('billing_first_name', $firstName);
$this->type('billing_last_name', $lastName);
$this->type("xpath=//input[@class='form-text four required']", "1");
$this->click("xpath=//input[@class='form-radio']");
$this->click("xpath=//input[@class='form-checkbox']");
Expand All @@ -473,8 +461,8 @@ function testContributeOnlineWithPriceSet() {
$this->select('credit_card_exp_date[Y]', 'value=2020');

//Billing Info
$this->type('billing_first_name', $firstName . 'billing');
$this->type('billing_last_name', $lastName . 'billing');
$this->type('billing_first_name', $firstName);
$this->type('billing_last_name', $lastName);
$this->type('billing_street_address-5', '15 Main St.');
$this->type('billing_city-5', 'San Jose');
$this->select('billing_country_id-5', 'value=1228');
Expand Down Expand Up @@ -509,28 +497,18 @@ function testContributeOnlineWithPriceSet() {
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForElementPresent("_qf_ContributionView_cancel-bottom");

//View Contribution Record
// View Contribution Record and test for expected values
$expected = array(
2 => $financialType,
5 => '$ 590.00',
8 => 'Completed',
'From' => "{$firstName} {$lastName}",
'Financial Type' => $financialType,
'Net Amount' => '$ 590.00',
'Contribution Status' => 'Completed',
);
foreach($expected as $label => $value) {
$this->verifyText("xpath=//form[@id='ContributionView']/div[2]/table/tbody/tr[$label]/td[2]", preg_quote($value));
}
$this->webtestVerifyTabularData($expected);

}

function testContributeWithDateSpecificPriceSet() {
// This is the path where our testing install resides.
// The rest of URL is defined in CiviSeleniumTestCase base class, in
// class attributes.
$this->open($this->sboxPath);

// Logging in. Remember to wait for page to load. In most cases,
// you can rely on 30000 as the value that allows your test to pass, however,
// sometimes your test might fail because of this. In such cases, it's better to pick one element
// somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
// page contents loaded and you can continue your test execution.
$this->webtestLogin();

//add financial type of account type expense
Expand Down Expand Up @@ -601,8 +579,6 @@ function testContributeWithDateSpecificPriceSet() {
$lastName = 'An' . substr(sha1(rand()), 0, 7);
$this->waitForElementPresent('_qf_Main_upload-bottom');
$this->type('email-5', $firstName . '@example.com');
$this->type('billing_first_name', $firstName);
$this->type('billing_last_name', $lastName);
$this->click("xpath=//input[@class='form-radio']");
$this->click("xpath=//input[@class='form-checkbox']");

Expand All @@ -621,8 +597,8 @@ function testContributeWithDateSpecificPriceSet() {
$this->select('credit_card_exp_date[Y]', 'value=2020');

//Billing Info
$this->type('billing_first_name', $firstName . 'billing');
$this->type('billing_last_name', $lastName . 'billing');
$this->type('billing_first_name', $firstName);
$this->type('billing_last_name', $lastName);
$this->type('billing_street_address-5', '15 Main St.');
$this->type(' billing_city-5', 'San Jose');
$this->select('billing_country_id-5', 'value=1228');
Expand Down Expand Up @@ -657,23 +633,17 @@ function testContributeWithDateSpecificPriceSet() {
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForElementPresent('_qf_ContributionView_cancel-bottom');

//View Contribution Record
// View Contribution Record and test for expected values
$expected = array(
2 => $financialType,
5 => '65.00',
8 => 'Completed',
'From' => "{$firstName} {$lastName}",
'Financial Type' => $financialType,
'Net Amount' => '$ 65.00',
'Contribution Status' => 'Completed',
);
foreach($expected as $label => $value) {
$this->verifyText("xpath=//form[@id='ContributionView']/div[2]/table/tbody/tr[$label]/td[2]", preg_quote($value));
}
$this->webtestVerifyTabularData($expected);
}

function testContributeOfflineforSoftcreditwithApi() {
// This is the path where our testing install resides.
// The rest of URL is defined in CiviSeleniumTestCase base class, in
// class attributes.
$this->open($this->sboxPath);

// Log in using webtestLogin() method
$this->webtestLogin();

Expand Down Expand Up @@ -738,7 +708,7 @@ function testContributeOfflineforSoftcreditwithApi() {
// select payment instrument type = Check and enter chk number
$this->select('payment_instrument_id', 'value=4');
$this->waitForElementPresent('check_number');
$this->type('check_number', 'check #1041');
$this->type('check_number', '1041');

$this->type('trxn_id', 'P20901X1' . rand(100, 10000));

Expand All @@ -751,9 +721,6 @@ function testContributeOfflineforSoftcreditwithApi() {
$this->waitForElementPresent('thankyou_date');

$this->type('note', 'This is a test note.');
$this->type('non_deductible_amount', '10');
$this->type('fee_amount', '0');
$this->type('net_amount', '0');
$this->type('invoice_id', time());
$this->webtestFillDate('thankyou_date');

Expand All @@ -762,25 +729,24 @@ function testContributeOfflineforSoftcreditwithApi() {
$this->waitForPageToLoad($this->getTimeoutMsec());

// Is status message correct?
$this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");

$this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
$this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");

//click through to the Membership view screen
//click through to the Contribution view screen
$this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
$this->waitForElementPresent('_qf_ContributionView_cancel-bottom');

// View Contribution Record and test for expected values
$expected = array(
2 => $financialType,
3 => '590.00',
9 => 'Completed',
10 => 'Check',
11 => 'check #1041',
17 => "$firstNameSoft $lastNameSoft",
'From' => "{$firstName} Contributor",
'Financial Type' => $financialType,
'Contribution Amount' => 'Contribution Total: $ 590.00',
'Paid By' => 'Check',
'Check Number' => '1041',
'Contribution Status' => 'Completed',
'Soft Credit To' => "$firstNameSoft $lastNameSoft",
);
foreach ($expected as $label => $value) {
$this->verifyText("xpath=//form[@id='ContributionView']/div[2]/table/tbody/tr[$label]/td[2]", preg_quote($value));
}
$this->webtestVerifyTabularData($expected);

$exp = array(
2 => '$ 525.00',
Expand All @@ -793,7 +759,7 @@ function testContributeOfflineforSoftcreditwithApi() {
preg_quote($val)
);
}

// Check for Soft contact created
$this->click("css=input#sort_name_navigation");
$this->type("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
Expand All @@ -812,29 +778,30 @@ function testContributeOfflineforSoftcreditwithApi() {
$this->click("xpath=id('rowid')/td[7]/a");
$this->waitForElementPresent('_qf_ContributionView_cancel-bottom');

foreach ($expected as $label => $value) {
$this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
}
$this->webtestVerifyTabularData($expected);

$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 );

$params['id'] = $params['contact_id'] = $fields['values'][$fields['id']]['soft_credit_to'];
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);
$expected = array(1 => $fields['values'][$fields['id']]['display_name'],
2 => $fields['values'][$fields['id']]['financial_type'],
3 => $fields['values'][$fields['id']]['total_amount'],
9 => $fields['values'][$fields['id']]['contribution_status'],
10 => $fields['values'][$fields['id']]['contribution_payment_instrument'],
11 => $fields['values'][$fields['id']]['contribution_check_number'],
17 => $contact->display_name,
$softCreditContact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);

// View Contribution Record and test for expected values
$expected = array(
'From' => $fields['values'][$fields['id']]['display_name'],
'Financial Type' => $fields['values'][$fields['id']]['financial_type'],
'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'],
'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'],
'Paid By' => $fields['values'][$fields['id']]['contribution_payment_instrument'],
'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'],
'Soft Credit To' => $softCreditContact->display_name,
);
foreach ($expected as $label => $value) {
$this->verifyText("xpath=//form[@id='ContributionView']/div[2]/table/tbody/tr[$label]/td[2]", preg_quote($value));
}
$this->webtestVerifyTabularData($expected);
}
}

0 comments on commit 5af3d50

Please sign in to comment.