Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
2fe49090 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 TO |
26 | |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
28 | ||
e9479dcf EM |
29 | /** |
30 | * Class WebTest_Financial_FinancialAccountTypeTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase { |
33 | ||
00be9182 | 34 | public function testFinancialAccount() { |
76e86fd8 CW |
35 | // To Add Financial Account |
36 | ||
6a488035 | 37 | // class attributes. |
76e86fd8 | 38 | |
6a488035 TO |
39 | // Log in using webtestLogin() method |
40 | $this->webtestLogin(); | |
76e86fd8 | 41 | |
6a488035 | 42 | //Add new Financial Type |
92fcb95f | 43 | $financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4); |
6c6e6187 TO |
44 | $financialType['is_deductible'] = TRUE; |
45 | $financialType['is_reserved'] = FALSE; | |
6a488035 | 46 | $this->addeditFinancialType($financialType); |
f17d75bb PN |
47 | $expected = array( |
48 | array( | |
49 | 'financial_account' => $financialType['name'], | |
50 | 'account_relationship' => "Income Account is", | |
51 | ), | |
52 | array( | |
53 | 'financial_account' => 'Banking Fees', | |
54 | 'account_relationship' => 'Expense Account is', | |
55 | ), | |
56 | array( | |
57 | 'financial_account' => 'Accounts Receivable', | |
58 | 'account_relationship' => 'Accounts Receivable Account is', | |
59 | ), | |
60 | array( | |
61 | 'financial_account' => 'Premiums', | |
62 | 'account_relationship' => 'Cost of Sales Account is', | |
63 | ), | |
6a488035 | 64 | ); |
e9479dcf | 65 | |
6cbe4dc3 | 66 | $this->waitForElementPresent('newFinancialType'); |
9fdcdf6f | 67 | $this->click("xpath=id('ltype')/div/table/tbody//tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']"); |
6cbe4dc3 | 68 | $this->waitForElementPresent('newfinancialTypeAccount'); |
e9479dcf | 69 | |
6c6e6187 | 70 | foreach ($expected as $value => $label) { |
6cbe4dc3 | 71 | $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='$label[financial_account]']/../td[1]", preg_quote($label['account_relationship'])); |
6a488035 | 72 | } |
e9479dcf | 73 | |
e5051498 | 74 | $this->openCiviPage('admin/financial/financialType', 'reset=1', 'newFinancialType'); |
9fdcdf6f WA |
75 | $this->verifyText("xpath=id('ltype')/div/table/tbody//tr/td[1]/div[text()='$financialType[name]']/../../td[3]", 'Accounts Receivable,Banking Fees,Premiums,' . $financialType['name']); |
76 | $this->click("xpath=id('ltype')/div/table/tbody//tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']"); | |
6a488035 | 77 | $this->waitForElementPresent('newfinancialTypeAccount'); |
9fdcdf6f | 78 | $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Banking Fees']/../td[7]/span/a[text()='Edit']"); |
6a488035 TO |
79 | $this->waitForElementPresent('_qf_FinancialTypeAccount_next'); |
80 | $this->select('account_relationship', "value=select"); | |
c51f8adb | 81 | $this->waitForElementPresent("xpath=//select[@id='account_relationship']/option[text()='- Select Financial Account Relationship -']"); |
f17d75bb | 82 | $this->select('account_relationship', "label=Premiums Inventory Account is"); |
c51f8adb | 83 | $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']"); |
f17d75bb | 84 | $this->select('financial_account_id', "label=Premiums inventory"); |
6a488035 | 85 | $this->click('_qf_FinancialTypeAccount_next'); |
9fdcdf6f WA |
86 | $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Edit']"); |
87 | $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Premiums inventory']/../td[1]", preg_quote('Premiums Inventory Account is')); | |
88 | $this->clickLink("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom', FALSE); | |
6a488035 | 89 | $this->click('_qf_FinancialTypeAccount_next-botttom'); |
6c5f7368 | 90 | $this->waitForText('crm-notification-container', 'Selected financial type account has been deleted.'); |
76e86fd8 | 91 | |
6a488035 TO |
92 | //edit financial type |
93 | $financialType['oldname'] = $financialType['name']; | |
92fcb95f | 94 | $financialType['name'] = 'Edited FinancialType ' . substr(sha1(rand()), 0, 4); |
6c6e6187 TO |
95 | $financialType['is_deductible'] = TRUE; |
96 | $financialType['is_reserved'] = FALSE; | |
97 | $this->addeditFinancialType($financialType, 'Edit'); | |
6a488035 | 98 | //delete financialtype |
6c6e6187 | 99 | $this->addeditFinancialType($financialType, 'Delete'); |
6a488035 | 100 | } |
96025800 | 101 | |
232624b1 | 102 | } |