- );
- $this->addeditFinancialType($financialType);
- $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
- $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
- $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']");
- $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom", FALSE);
-
- $this->select("account_relationship", "label=Premiums Inventory Account is");
- $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
- $this->select("financial_account_id", "label=$to");
- $this->clickLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']", FALSE);
- $premiumName = 'Premium' . substr(sha1(rand()), 0, 7);
- $amount = 500;
- $sku = 'SKU';
- $price = 300;
- $cost = 3.00;
- $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
- // add premium
- $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
-
- // add contribution with premium
- $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone");
-
- // create new contact using dialog
- $this->createDialogContact();
- // select financial type
- $this->select("financial_type_id", "value=1");
- // total amount
- $this->type("total_amount", "100");
- // fill Premium information
- $this->click("xpath=//div[@id='Premium']");
- $this->waitForElementPresent("product_name_0");
- $this->select('product_name_0', "label=$premiumName ( $sku )");
- // Clicking save.
- $this->clickLink("_qf_Contribution_upload");
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
- // verify if Contribution is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
- //click through to the Contribution edit screen
- $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom", FALSE);
- $this->waitForElementPresent("product_name_0");
- $this->select('product_name_0', "value=0");
- // Clicking save.
- $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[7][not(text())]", FALSE);
-
- //Assertions
- $actualAmount = $this->_getPremiumActualCost($contId, $from, $to, NULL, "'civicrm_contribution'");
- $this->assertEquals($actualAmount, $cost, "Verify actual cost for deleted premium");
- }
-
- function testChangePaymentInstrument() {
- $this->webtestLogin();
- $label = 'TEST'.substr(sha1(rand()), 0, 7);
- $amount = 100.00;
- $financialAccount = CRM_Contribute_PseudoConstant::financialAccount();
- $to = array_search('Accounts Receivable', $financialAccount);
- $from = array_search('Deposit Bank Account', $financialAccount);
- $this->addPaymentInstrument($label, $to);
- $this->_testOfflineContribution($amount);
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
- $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- //change payment processor to newly created value
- $this->select("payment_instrument_id", "label=$label");
- $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
- $this->waitForAjaxContent();
- //Assertions
- $subtractedTotal = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account');
- $this->assertEquals($subtractedTotal, -$amount, "Verify amount deleted from old account");
- $totalAmount = $this->_getPremiumActualCost($contId, NULL, 'Accounts Receivable');
- $this->assertEquals($totalAmount, $amount, "Verify amount for newly inserted values");
- }
-
- function testRefundContribution() {
- $this->webtestLogin();
- $amount = 100.00;
- $this->_testOfflineContribution($amount);
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $this->clickAjaxLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom');
- //Contribution status
- $this->select("contribution_status_id", "label=Refunded");
- $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- $this->clickAjaxLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[6][text()='Refunded']");
-
- //Assertions
- $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
- $search = array('entity_id' => $lineItem);
- $compare = array(
+ );
+ $this->addeditFinancialType($financialType);
+ $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
+ $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
+ $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']");
+ $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom", FALSE);
+
+ $this->select("account_relationship", "label=Premiums Inventory Account is");
+ $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
+ $this->select("financial_account_id", "label=$to");
+ $this->clickLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']", FALSE);
+ $premiumName = 'Premium' . substr(sha1(rand()), 0, 7);
+ $amount = 500;
+ $sku = 'SKU';
+ $price = 300;
+ $cost = 3.00;
+ $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
+ // add premium
+ $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
+
+ // add contribution with premium
+ $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone");
+
+ // create new contact using dialog
+ $this->createDialogContact();
+ // select financial type
+ $this->select("financial_type_id", "value=1");
+ // total amount
+ $this->type("total_amount", "100");
+ // fill Premium information
+ $this->click("xpath=//div[@id='Premium']");
+ $this->waitForElementPresent("product_name_0");
+ $this->select('product_name_0', "label=$premiumName ( $sku )");
+ // Clicking save.
+ $this->clickLink("_qf_Contribution_upload");
+ // Is status message correct?
+ $this->waitForText('crm-notification-container', "The contribution record has been saved.");
+ // verify if Contribution is created
+ $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
+ //click through to the Contribution edit screen
+ $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
+ $contId = explode('&', $contId[1]);
+ $contId = $contId[0];
+ $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom", FALSE);
+ $this->waitForElementPresent("product_name_0");
+ $this->select('product_name_0', "value=0");
+ // Clicking save.
+ $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[7][not(text())]", FALSE);
+
+ //Assertions
+ $actualAmount = $this->_getPremiumActualCost($contId, $from, $to, NULL, "'civicrm_contribution'");
+ $this->assertEquals($actualAmount, $cost, "Verify actual cost for deleted premium");
+ }
+
+ public function testChangePaymentInstrument() {
+ $this->webtestLogin();
+ $label = 'TEST'.substr(sha1(rand()), 0, 7);
+ $amount = 100.00;
+ $financialAccount = CRM_Contribute_PseudoConstant::financialAccount();
+ $to = array_search('Accounts Receivable', $financialAccount);
+ $from = array_search('Deposit Bank Account', $financialAccount);
+ $this->addPaymentInstrument($label, $to);
+ $this->_testOfflineContribution($amount);
+ $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+ $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
+ $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
+ $contId = explode('&', $contId[1]);
+ $contId = $contId[0];
+ //change payment processor to newly created value
+ $this->select("payment_instrument_id", "label=$label");
+ $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
+ $this->waitForAjaxContent();
+ //Assertions
+ $subtractedTotal = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account');
+ $this->assertEquals($subtractedTotal, -$amount, "Verify amount deleted from old account");
+ $totalAmount = $this->_getPremiumActualCost($contId, NULL, 'Accounts Receivable');
+ $this->assertEquals($totalAmount, $amount, "Verify amount for newly inserted values");
+ }
+
+ public function testRefundContribution() {
+ $this->webtestLogin();
+ $amount = 100.00;
+ $this->_testOfflineContribution($amount);
+ $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+ $this->clickAjaxLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom');
+ //Contribution status
+ $this->select("contribution_status_id", "label=Refunded");
+ $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
+ $contId = explode('&', $contId[1]);
+ $contId = $contId[0];
+ $this->clickAjaxLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[6][text()='Refunded']");
+
+ //Assertions
+ $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
+ $search = array('entity_id' => $lineItem);
+ $compare = array(