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';
29 class WebTest_Financial_FinancialAccountTest
extends CiviSeleniumTestCase
{
32 * Test To Add Financial Account class attributes.
34 function testFinancialAccount() {
35 $this->webtestLogin();
37 // Add new Financial Account
38 $orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
39 $uniqueName = explode(" ",$orgName);
40 $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
41 $financialAccountDescription = "{$financialAccountTitle} Description";
42 $accountingCode = 1033;
43 $financialAccountType = 'Expenses';
44 $taxDeductible = FALSE;
47 $taxRate = 9.99999999;
50 //Add new organisation
52 $this->webtestAddOrganization($orgName);
55 $this->_testAddFinancialAccount($financialAccountTitle,
56 $financialAccountDescription,
59 $financialAccountType,
67 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
69 $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
70 //Varify Data after Adding new Financial Account
71 $verifyData = array('name' => $financialAccountTitle,
72 'description' => $financialAccountDescription,
73 'accounting_code' => $accountingCode,
74 'tax_rate' => $taxRate,
76 'is_deductible' => 'off',
80 $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
82 $this->_assertFinancialAccount($verifyData);
83 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
84 $this->_assertSelectVerify($verifySelectFieldData);
85 $this->click('_qf_FinancialAccount_cancel-botttom');
87 //Edit Financial Account
88 $editfinancialAccount = $financialAccountTitle;
89 $financialAccountTitle .= ' Edited';
91 $financialAccountType = 'Revenue';
94 $orgNameEdit = 'NGO '.substr(sha1(rand()), 0, 7);
95 $this->webtestAddOrganization($orgNameEdit);
96 $uniqueName = explode(" ",$orgNameEdit);
99 $this->_testEditFinancialAccount($editfinancialAccount,
100 $financialAccountTitle,
101 $financialAccountDescription,
104 $financialAccountType,
113 $orgName = $orgNameEdit;
115 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
116 $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
118 $verifyData = array( 'name' => $financialAccountTitle,
119 'description' => $financialAccountDescription,
120 'accounting_code' => $accountingCode,
121 'tax_rate' => $taxRate,
123 'is_deductible' => 'off',
124 'is_default' => 'off',
127 $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
129 $this->_assertFinancialAccount($verifyData);
130 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
131 $this->_assertSelectVerify($verifySelectFieldData);
132 $this->click('_qf_FinancialAccount_cancel-botttom');
133 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Delete']");
135 //Delete Financial Account
136 $this->_testDeleteFinancialAccount($financialAccountTitle);