Mass switch to openCiviPage method
[civicrm-core.git] / tests / phpunit / WebTest / Financial / FinancialAccountTest.php
CommitLineData
6a488035
TO
1<?php
2
3/*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
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. |
14 | |
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. |
19 | |
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 +--------------------------------------------------------------------+
26*/
27
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase {
30
071a6d2e
CW
31 /**
32 * Test To Add Financial Account class attributes.
33 */
6a488035 34 function testFinancialAccount() {
6a488035
TO
35 $this->webtestLogin();
36
37 // Add new Financial Account
38 $orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
39 $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
40 $financialAccountDescription = "{$financialAccountTitle} Description";
41 $accountingCode = 1033;
42 $financialAccountType = 'Expenses';
43 $taxDeductible = FALSE;
44 $isActive = TRUE;
45 $isTax = TRUE;
46 $taxRate = 9.99999999;
47 $isDefault = FALSE;
48
49 //Add new organisation
50 if($orgName) {
51 $this->webtestAddOrganization($orgName);
52 }
53
54 $this->_testAddFinancialAccount($financialAccountTitle,
55 $financialAccountDescription,
56 $accountingCode,
57 $orgName,
58 $financialAccountType,
59 $taxDeductible,
60 $isActive,
61 $isTax,
62 $taxRate,
63 $isDefault
64 );
65
66 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
67
68 $this->click("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
69 $this->waitForPageToLoad($this->getTimeoutMsec());
70 $this->waitForElementPresent('_qf_FinancialAccount_cancel-botttom');
71 //Varify Data after Adding new Financial Account
72 $verifyData = array('name' => $financialAccountTitle,
73 'description' => $financialAccountDescription,
74 'accounting_code' => $accountingCode,
75 'contact_name' => $orgName,
76 'tax_rate' => $taxRate,
77 'is_tax' => 'on',
78 'is_deductible' => 'off',
79 'is_default' => 'off'
80 );
81
82 $this->_assertFinancialAccount($verifyData);
83 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
84 $this->_assertSelectVerify($verifySelectFieldData);
85 $this->click('_qf_FinancialAccount_cancel-botttom');
86
87 //Edit Financial Account
88 $editfinancialAccount = $financialAccountTitle;
89 $financialAccountTitle .= ' Edited';
90 $orgNameEdit = FALSE;
91 $financialAccountType = 'Revenue';
92
93 if ($orgNameEdit) {
94 $orgNameEdit = 'NGO '.substr(sha1(rand()), 0, 7);
95 $this->webtestAddOrganization($orgNameEdit);
96 }
97
98 $this->_testEditFinancialAccount($editfinancialAccount,
99 $financialAccountTitle,
100 $financialAccountDescription,
101 $accountingCode,
102 $orgNameEdit,
103 $financialAccountType,
104 $taxDeductible,
105 $isActive,
106 $isTax,
107 $taxRate,
108 $isDefault
109 );
110 if($orgNameEdit) {
111 $orgName = $orgNameEdit;
112 }
113 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
114 $this->click("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
115 $this->waitForPageToLoad($this->getTimeoutMsec());
116 $this->waitForElementPresent('_qf_FinancialAccount_cancel-botttom');
117
118 $verifyData = array( 'name' => $financialAccountTitle,
119 'description' => $financialAccountDescription,
120 'accounting_code' => $accountingCode,
121 'contact_name' => $orgName,
122 'tax_rate' => $taxRate,
123 'is_tax' => 'on',
124 'is_deductible' => 'off',
125 'is_default' => 'off',
126 );
127 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
128 $this->_assertFinancialAccount($verifyData);
129 $this->_assertSelectVerify($verifySelectFieldData);
130 $this->click('_qf_FinancialAccount_cancel-botttom');
131 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Delete']");
132
133 //Delete Financial Account
134 $this->_testDeleteFinancialAccount($financialAccountTitle);
135 }
136}