INFRA-132 - FunctionDeclarationArgumentSpacing.SpaceBeforeEquals
[civicrm-core.git] / tests / phpunit / WebTest / Financial / FinancialAccountTest.php
CommitLineData
6a488035
TO
1<?php
2
3/*
4 +--------------------------------------------------------------------+
39de6fd5 5 | CiviCRM version 4.6 |
6a488035 6 +--------------------------------------------------------------------+
06a1bc01 7 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
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';
e9479dcf
EM
29
30/**
31 * Class WebTest_Financial_FinancialAccountTest
32 */
6a488035
TO
33class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase {
34
071a6d2e
CW
35 /**
36 * Test To Add Financial Account class attributes.
37 */
00be9182 38 public function testFinancialAccount() {
6a488035 39 $this->webtestLogin();
76e86fd8 40
6a488035 41 // Add new Financial Account
92fcb95f 42 $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
6c6e6187 43 $uniqueName = explode(" ", $orgName);
92fcb95f 44 $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
6a488035
TO
45 $financialAccountDescription = "{$financialAccountTitle} Description";
46 $accountingCode = 1033;
1187b883 47 $financialAccountType = 'Liability';
6a488035
TO
48 $taxDeductible = FALSE;
49 $isActive = TRUE;
50 $isTax = TRUE;
51 $taxRate = 9.99999999;
52 $isDefault = FALSE;
76e86fd8 53
6a488035 54 //Add new organisation
22e263ad 55 if ($orgName) {
6a488035
TO
56 $this->webtestAddOrganization($orgName);
57 }
76e86fd8 58
6a488035
TO
59 $this->_testAddFinancialAccount($financialAccountTitle,
60 $financialAccountDescription,
61 $accountingCode,
6cbe4dc3 62 $uniqueName[1],
6a488035
TO
63 $financialAccountType,
64 $taxDeductible,
65 $isActive,
66 $isTax,
67 $taxRate,
68 $isDefault
69 );
76e86fd8 70
4a058f26 71 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']");
76e86fd8 72
4a058f26 73 $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
6a488035 74 //Varify Data after Adding new Financial Account
6c6e6187
TO
75 $verifyData = array(
76 'name' => $financialAccountTitle,
6a488035
TO
77 'description' => $financialAccountDescription,
78 'accounting_code' => $accountingCode,
6a488035
TO
79 'tax_rate' => $taxRate,
80 'is_tax' => 'on',
81 'is_deductible' => 'off',
21dfd5f5 82 'is_default' => 'off',
6a488035 83 );
e9479dcf 84
6cbe4dc3 85 $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
76e86fd8 86
6a488035
TO
87 $this->_assertFinancialAccount($verifyData);
88 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
89 $this->_assertSelectVerify($verifySelectFieldData);
90 $this->click('_qf_FinancialAccount_cancel-botttom');
76e86fd8 91
6a488035
TO
92 //Edit Financial Account
93 $editfinancialAccount = $financialAccountTitle;
94 $financialAccountTitle .= ' Edited';
95 $orgNameEdit = FALSE;
1187b883 96 $financialAccountType = 'Liability';
76e86fd8 97
6a488035 98 if ($orgNameEdit) {
92fcb95f 99 $orgNameEdit = 'NGO ' . substr(sha1(rand()), 0, 7);
6a488035 100 $this->webtestAddOrganization($orgNameEdit);
6c6e6187 101 $uniqueName = explode(" ", $orgNameEdit);
6a488035 102 }
76e86fd8 103
6a488035
TO
104 $this->_testEditFinancialAccount($editfinancialAccount,
105 $financialAccountTitle,
106 $financialAccountDescription,
107 $accountingCode,
6cbe4dc3 108 $uniqueName[1],
6a488035
TO
109 $financialAccountType,
110 $taxDeductible,
111 $isActive,
112 $isTax,
113 $taxRate,
114 $isDefault
76e86fd8
CW
115 );
116
22e263ad 117 if ($orgNameEdit) {
6a488035
TO
118 $orgName = $orgNameEdit;
119 }
4a058f26
WA
120 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']");
121 $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
76e86fd8 122
6c6e6187
TO
123 $verifyData = array(
124 'name' => $financialAccountTitle,
6a488035
TO
125 'description' => $financialAccountDescription,
126 'accounting_code' => $accountingCode,
6a488035
TO
127 'tax_rate' => $taxRate,
128 'is_tax' => 'on',
129 'is_deductible' => 'off',
130 'is_default' => 'off',
131 );
e9479dcf 132
6cbe4dc3 133 $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
e9479dcf 134
6a488035 135 $this->_assertFinancialAccount($verifyData);
6c6e6187 136 $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
6a488035
TO
137 $this->_assertSelectVerify($verifySelectFieldData);
138 $this->click('_qf_FinancialAccount_cancel-botttom');
4a058f26 139 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Delete']");
76e86fd8 140
6a488035
TO
141 //Delete Financial Account
142 $this->_testDeleteFinancialAccount($financialAccountTitle);
143 }
144}