webtestLogin(); // Create a contact to be used as soft creditor $softCreditFname = substr(sha1(rand()), 0, 7); $softCreditLname = substr(sha1(rand()), 0, 7); $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE); // 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 = 'Asset'; $taxDeductible = FALSE; $isActive = FALSE; $isTax = TRUE; $taxRate = 9.9999999; $isDefault = FALSE; //Add new organisation if ($orgName) { $this->webtestAddOrganization($orgName); } $this->_testAddFinancialAccount($financialAccountTitle, $financialAccountDescription, $accountingCode, $orgName, $financialAccountType, $taxDeductible, $isActive, $isTax, $taxRate, $isDefault ); $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); // create new contact using dialog $contact = $this->createDialogContact(); // select financial type $this->select("financial_type_id", "value=1"); // fill in Received Date $this->webtestFillDate('receive_date'); // source $this->type("source", "Mailer 1"); // total amount $this->type("total_amount", "100"); // 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->click("is_email_receipt"); $this->assertTrue($this->isChecked("is_email_receipt"), 'Send Receipt checkbox should be checked.'); $this->type("trxn_id", "P20901X1" . rand(100, 10000)); // soft credit $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 's2id_soft_credit_contact_id_1'); $this->type("soft_credit_amount_1", "100"); //Custom Data //$this->click('CIVICRM_QFID_3_6'); //Additional Detail section $this->click("AdditionalDetail"); $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'); //Premium section $this->click("Premium"); $this->waitForElementPresent("fulfilled_date"); $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )"); $this->select("product_name[1]", "label=Black"); $this->webtestFillDate('fulfilled_date'); // Clicking save. $this->click("_qf_Contribution_upload"); // Ask for confirmation to send a receipt to the contributor on 'is_email_reciept' check $this->assertTrue((bool) preg_match("/^Click OK to save this contribution record AND send a receipt to the contributor now./", $this->getConfirmation())); $this->chooseOkOnNextConfirmation(); $this->waitForPageToLoad($this->getTimeoutMsec()); // Is status message correct? $this->waitForText("crm-notification-container", "The contribution record has been saved."); // verify if Membership 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 Membership view screen $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); $expected = array( 'Financial Type' => 'Donation', 'Total Amount' => '$ 100.00', 'Contribution Status' => 'Completed', 'Payment Method' => 'Check', 'Check Number' => 'check #1041', ); foreach ($expected as $label => $value) { $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value)); } // verify if soft credit was created successfully $expected = array( 'Soft Credit To' => "{$softCreditFname} {$softCreditLname}", 'Amount' => '100.00', ); foreach ($expected as $value) { $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value)); } // go to first soft creditor contact view page $this->clickLink("css=table.crm-soft-credit-listing tbody tr td a"); // go to contribution tab $this->waitForElementPresent("css=li#tab_contribute a"); $this->click("css=li#tab_contribute a"); $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)"); $this->verifyText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[1]/a", preg_quote($contact['display_name'])); // verify soft credit details $expected = array( 4 => 'Donation', 2 => '100.00', 6 => 'Completed', ); foreach ($expected as $value => $label) { $this->verifyText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[$value]", preg_quote($label)); } } public function testfinancialTypeSearch() { $this->webtestLogin(); $financialType = array( 'name' => 'Financial type' . substr(sha1(rand()), 0, 7), 'is_reserved' => FALSE, 'is_deductible' => FALSE, ); $this->addeditFinancialType($financialType); $this->addStandaloneContribution($financialType); $this->addStandaloneContribution($financialType); $this->openCiviPage("contribute/search", "reset=1", "_qf_Search_refresh"); // select group $this->select("financial_type_id", "label={$financialType['name']}"); $this->clickLink("_qf_Search_refresh"); $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", "2 Result"); $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[2]", "Financial Type ID In {$financialType['name']}"); $this->openCiviPage("contact/search/advanced", "reset=1", "_qf_Advanced_refresh-top"); $this->clickAjaxLink('CiviContribute', "financial_type_id"); // select group $this->select("financial_type_id", "label={$financialType['name']}"); $this->clickLink("_qf_Advanced_refresh-top"); $this->assertElementContainsText("xpath=//div[@id='search-status']//table/tbody/tr[1]/td[1]", "2 Contacts"); $this->assertElementContainsText("xpath=//div[@id='search-status']//table/tbody/tr[1]/td[2]", "Financial Type ID In {$financialType['name']}"); } /** * @param $financialType */ public function addStandaloneContribution($financialType) { $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); // create new contact using dialog $this->createDialogContact(); // select financial type $this->select("financial_type_id", "label={$financialType['name']}"); // fill in Received Date $this->webtestFillDate('receive_date'); // source $this->type("source", "Mailer 1"); // total amount $this->type("total_amount", "100"); // 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("trxn_id", "P20901X1" . rand(100, 10000)); //Additional Detail section $this->click("AdditionalDetail"); $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'); // Clicking save. $this->clickLink("_qf_Contribution_upload"); // Is status message correct? $this->checkCRMAlert("The contribution record has been saved."); // verify if Membership 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 Membership view screen $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); $expected = array( 'Financial Type' => $financialType['name'], 'Total Amount' => '$ 100.00', 'Contribution Status' => 'Completed', 'Payment Method' => 'Check', 'Check Number' => 'check #1041', ); foreach ($expected as $label => $value) { $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value)); } } public function testAjaxCustomGroupLoad() { $this->webtestLogin(); $triggerElement = array('name' => 'financial_type_id', 'type' => 'select'); $customSets = array( array('entity' => 'Contribution', 'subEntity' => 'Donation', 'triggerElement' => $triggerElement), array('entity' => 'Contribution', 'subEntity' => 'Member Dues', 'triggerElement' => $triggerElement), ); $pageUrl = array('url' => 'contribute/add', 'args' => 'reset=1&action=add&context=standalone'); $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl); } }