4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License along with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 class WebTest_Financial_FinancialAccountTypeTest
extends CiviSeleniumTestCase
{
32 function testFinancialAccount() {
33 // To Add Financial Account
37 // Log in using webtestLogin() method
38 $this->webtestLogin();
40 // Add new Financial Account
41 $orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
42 $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
43 $financialAccountDescription = "{$financialAccountTitle} Description";
44 $accountingCode = 1033;
45 $financialAccountType = 'Revenue';
46 $taxDeductible = FALSE;
52 //Add new organisation
54 $this->webtestAddOrganization($orgName);
57 $this->_testAddFinancialAccount(
59 $financialAccountTitle,
60 $financialAccountDescription,
63 $financialAccountType,
71 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
73 $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom');
75 //Varify Data after Adding new Financial Account
78 'name' => $financialAccountTitle,
79 'description' => $financialAccountDescription,
80 'accounting_code' => $accountingCode,
81 'contact_name' => $orgName,
82 'tax_rate' => $taxRate,
84 'is_deductible' => 'off',
85 'is_default' => 'off',
88 $this->_assertFinancialAccount($verifyData);
89 $verifySelectFieldData = array(
90 'financial_account_type_id' => $financialAccountType,
92 $this->_assertSelectVerify($verifySelectFieldData);
93 $this->click('_qf_FinancialAccount_cancel-botttom');
94 $this->waitForPageToLoad($this->getTimeoutMsec());
96 //Add new Financial Type
97 $financialType['name'] = 'FinancialType '.substr(sha1(rand()), 0, 4);
98 $financialType['is_deductible'] = true;
99 $financialType['is_reserved'] = false;
100 $this->addeditFinancialType($financialType);
101 $accountRelationship = "Income Account is";
104 'financial_account' => $financialAccountTitle,
106 'account_relationship' => $accountRelationship
110 $this->select('account_relationship', "label={$accountRelationship}");
111 $this->select('financial_account_id', "label={$financialAccountTitle}");
112 $this->click('_qf_FinancialTypeAccount_next_new');
113 $this->waitForPageToLoad($this->getTimeoutMsec());
114 $text = 'The financial type Account has been saved.';
115 $this->waitForText('crm-notification-container', $text);
116 $text = 'You can add another Financial Account Type.';
117 $this->waitForText('crm-notification-container', $text);
118 $accountRelationship = 'Expense Account is';
120 'financial_account' => 'Banking Fees',
121 'account_relationship' => $accountRelationship
124 $this->select('account_relationship', "label={$accountRelationship}");
125 $this->select('financial_account_id', "label=Banking Fees");
126 $this->click('_qf_FinancialTypeAccount_next');
127 $this->waitForElementPresent('newfinancialTypeAccount');
128 $text = 'The financial type Account has been saved.';
129 $this->waitForText('crm-notification-container', $text);
131 foreach ($expected as $value => $label) {
132 $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$label[financial_account]']/../td[2]", preg_quote($label['account_relationship']));
134 $this->openCiviPage('admin/financial/financialType', 'reset=1', 'newFinancialType');
135 $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[3]", $financialAccountTitle. ',Banking Fees');
136 $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span/a[text()='Accounts']");
137 $this->waitForElementPresent('newfinancialTypeAccount');
138 $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='Banking Fees']/../td[7]/span/a[text()='Edit']");
139 $this->waitForElementPresent('_qf_FinancialTypeAccount_next');
140 $this->select('account_relationship', "value=select");
141 // Because it tends to cause problems, all uses of sleep() must be justified in comments
142 // Sleep should never be used for wait for anything to load from the server
143 // Justification for this instance: FIXME
145 $this->select('account_relationship', "label=Accounts Receivable Account is");
146 $this->select('financial_account_id', "label=Accounts Receivable");
147 $this->click('_qf_FinancialTypeAccount_next');
148 $this->waitForElementPresent("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='Accounts Receivable']/../td[7]/span/a[text()='Edit']");
149 $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='Accounts Receivable']/../td[2]", preg_quote('Accounts Receivable Account is'));
150 $this->clickLink("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='Accounts Receivable']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom');
151 $this->click('_qf_FinancialTypeAccount_next-botttom');
152 $this->waitForPageToLoad($this->getTimeoutMsec());
153 $this->waitForText('crm-notification-container', 'Selected financial type account has been deleted.');
155 //edit financial type
156 $financialType['oldname'] = $financialType['name'];
157 $financialType['name'] = 'Edited FinancialType '.substr(sha1(rand()), 0, 4);
158 $financialType['is_deductible'] = true;
159 $financialType['is_reserved'] = false;
160 $this->addeditFinancialType($financialType , 'Edit');
161 //delete financialtype
162 $this->addeditFinancialType($financialType , 'Delete');