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