4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
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';
31 * Class WebTest_Financial_FinancialAccountTest
33 class WebTest_Financial_FinancialAccountTest
extends CiviSeleniumTestCase
{
36 * Test To Add Financial Account class attributes.
38 function testFinancialAccount() {
39 $this->webtestLogin();
41 // Add new Financial Account
42 $orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
43 $uniqueName = explode(" ",$orgName);
44 $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
45 $financialAccountDescription = "{$financialAccountTitle} Description";
46 $accountingCode = 1033;
47 $financialAccountType = 'Expenses';
48 $taxDeductible = FALSE;
51 $taxRate = 9.99999999;
54 //Add new organisation
56 $this->webtestAddOrganization($orgName);
59 $this->_testAddFinancialAccount($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', FALSE);
74 //Varify Data after Adding new Financial Account
75 $verifyData = array('name' => $financialAccountTitle,
76 'description' => $financialAccountDescription,
77 'accounting_code' => $accountingCode,
78 'tax_rate' => $taxRate,
80 'is_deductible' => 'off',
84 $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
86 $this->_assertFinancialAccount($verifyData);
87 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
88 $this->_assertSelectVerify($verifySelectFieldData);
89 $this->click('_qf_FinancialAccount_cancel-botttom');
91 //Edit Financial Account
92 $editfinancialAccount = $financialAccountTitle;
93 $financialAccountTitle .= ' Edited';
95 $financialAccountType = 'Revenue';
98 $orgNameEdit = 'NGO '.substr(sha1(rand()), 0, 7);
99 $this->webtestAddOrganization($orgNameEdit);
100 $uniqueName = explode(" ",$orgNameEdit);
103 $this->_testEditFinancialAccount($editfinancialAccount,
104 $financialAccountTitle,
105 $financialAccountDescription,
108 $financialAccountType,
117 $orgName = $orgNameEdit;
119 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
120 $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
122 $verifyData = array( 'name' => $financialAccountTitle,
123 'description' => $financialAccountDescription,
124 'accounting_code' => $accountingCode,
125 'tax_rate' => $taxRate,
127 'is_deductible' => 'off',
128 'is_default' => 'off',
131 $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
133 $this->_assertFinancialAccount($verifyData);
134 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
135 $this->_assertSelectVerify($verifySelectFieldData);
136 $this->click('_qf_FinancialAccount_cancel-botttom');
137 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Delete']");
139 //Delete Financial Account
140 $this->_testDeleteFinancialAccount($financialAccountTitle);