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 | ||
30 | class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase { | |
31 | ||
32 | function testFinancialAccount() { | |
76e86fd8 CW |
33 | // To Add Financial Account |
34 | ||
6a488035 | 35 | // class attributes. |
76e86fd8 | 36 | |
6a488035 TO |
37 | // Log in using webtestLogin() method |
38 | $this->webtestLogin(); | |
76e86fd8 | 39 | |
6a488035 TO |
40 | //Add new Financial Type |
41 | $financialType['name'] = 'FinancialType '.substr(sha1(rand()), 0, 4); | |
42 | $financialType['is_deductible'] = true; | |
43 | $financialType['is_reserved'] = false; | |
44 | $this->addeditFinancialType($financialType); | |
f17d75bb PN |
45 | $expected = array( |
46 | array( | |
47 | 'financial_account' => $financialType['name'], | |
48 | 'account_relationship' => "Income Account is", | |
49 | ), | |
50 | array( | |
51 | 'financial_account' => 'Banking Fees', | |
52 | 'account_relationship' => 'Expense Account is', | |
53 | ), | |
54 | array( | |
55 | 'financial_account' => 'Accounts Receivable', | |
56 | 'account_relationship' => 'Accounts Receivable Account is', | |
57 | ), | |
58 | array( | |
59 | 'financial_account' => 'Premiums', | |
60 | 'account_relationship' => 'Cost of Sales Account is', | |
61 | ), | |
6a488035 | 62 | ); |
f17d75bb | 63 | |
6a488035 | 64 | foreach ($expected as $value => $label) { |
15e9e899 | 65 | $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='$label[financial_account]']/../td[1]", preg_quote($label['account_relationship'])); |
6a488035 | 66 | } |
e5051498 | 67 | $this->openCiviPage('admin/financial/financialType', 'reset=1', 'newFinancialType'); |
f17d75bb | 68 | $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[3]", 'Accounts Receivable,Banking Fees,Premiums,' . $financialType['name']); |
6a488035 TO |
69 | $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span/a[text()='Accounts']"); |
70 | $this->waitForElementPresent('newfinancialTypeAccount'); | |
15e9e899 | 71 | $this->click("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Banking Fees']/../td[7]/span/a[text()='Edit']"); |
6a488035 TO |
72 | $this->waitForElementPresent('_qf_FinancialTypeAccount_next'); |
73 | $this->select('account_relationship', "value=select"); | |
efb29358 CW |
74 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
75 | // Sleep should never be used for wait for anything to load from the server | |
76 | // Justification for this instance: FIXME | |
6a488035 | 77 | sleep(1); |
f17d75bb PN |
78 | $this->select('account_relationship', "label=Premiums Inventory Account is"); |
79 | $this->select('financial_account_id', "label=Premiums inventory"); | |
6a488035 | 80 | $this->click('_qf_FinancialTypeAccount_next'); |
f17d75bb PN |
81 | $this->waitForElementPresent("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Edit']"); |
82 | $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[1]", preg_quote('Premiums Inventory Account is')); | |
83 | $this->clickLink("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom'); | |
6a488035 TO |
84 | $this->click('_qf_FinancialTypeAccount_next-botttom'); |
85 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 86 | $this->waitForText('crm-notification-container', 'Selected financial type account has been deleted.'); |
76e86fd8 | 87 | |
6a488035 TO |
88 | //edit financial type |
89 | $financialType['oldname'] = $financialType['name']; | |
90 | $financialType['name'] = 'Edited FinancialType '.substr(sha1(rand()), 0, 4); | |
91 | $financialType['is_deductible'] = true; | |
92 | $financialType['is_reserved'] = false; | |
93 | $this->addeditFinancialType($financialType , 'Edit'); | |
94 | //delete financialtype | |
95 | $this->addeditFinancialType($financialType , 'Delete'); | |
96 | } | |
232624b1 | 97 | } |