Webtests Fixes
[civicrm-core.git] / tests / phpunit / WebTest / Financial / FinancialAccountTypeTest.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';
29
e9479dcf
EM
30/**
31 * Class WebTest_Financial_FinancialAccountTypeTest
32 */
6a488035
TO
33class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase {
34
00be9182 35 public function testFinancialAccount() {
76e86fd8
CW
36 // To Add Financial Account
37
6a488035 38 // class attributes.
76e86fd8 39
6a488035
TO
40 // Log in using webtestLogin() method
41 $this->webtestLogin();
76e86fd8 42
6a488035 43 //Add new Financial Type
92fcb95f 44 $financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4);
6c6e6187
TO
45 $financialType['is_deductible'] = TRUE;
46 $financialType['is_reserved'] = FALSE;
6a488035 47 $this->addeditFinancialType($financialType);
f17d75bb
PN
48 $expected = array(
49 array(
50 'financial_account' => $financialType['name'],
51 'account_relationship' => "Income Account is",
52 ),
53 array(
54 'financial_account' => 'Banking Fees',
55 'account_relationship' => 'Expense Account is',
56 ),
57 array(
58 'financial_account' => 'Accounts Receivable',
59 'account_relationship' => 'Accounts Receivable Account is',
60 ),
61 array(
62 'financial_account' => 'Premiums',
63 'account_relationship' => 'Cost of Sales Account is',
64 ),
6a488035 65 );
e9479dcf 66
6cbe4dc3 67 $this->waitForElementPresent('newFinancialType');
4a058f26 68 $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']");
6cbe4dc3 69 $this->waitForElementPresent('newfinancialTypeAccount');
e9479dcf 70
6c6e6187 71 foreach ($expected as $value => $label) {
6cbe4dc3 72 $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='$label[financial_account]']/../td[1]", preg_quote($label['account_relationship']));
6a488035 73 }
e9479dcf 74
e5051498 75 $this->openCiviPage('admin/financial/financialType', 'reset=1', 'newFinancialType');
4a058f26
WA
76 $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[3]", 'Accounts Receivable,Banking Fees,Premiums,' . $financialType['name']);
77 $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']");
6a488035 78 $this->waitForElementPresent('newfinancialTypeAccount');
6cbe4dc3 79 $this->click("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='Banking Fees']/../td[7]/span/a[text()='Edit']");
6a488035
TO
80 $this->waitForElementPresent('_qf_FinancialTypeAccount_next');
81 $this->select('account_relationship', "value=select");
c51f8adb 82 $this->waitForElementPresent("xpath=//select[@id='account_relationship']/option[text()='- Select Financial Account Relationship -']");
f17d75bb 83 $this->select('account_relationship', "label=Premiums Inventory Account is");
c51f8adb 84 $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
f17d75bb 85 $this->select('financial_account_id', "label=Premiums inventory");
6a488035 86 $this->click('_qf_FinancialTypeAccount_next');
6cbe4dc3
AS
87 $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Edit']");
88 $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[1]", preg_quote('Premiums Inventory Account is'));
89 $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 90 $this->click('_qf_FinancialTypeAccount_next-botttom');
6c5f7368 91 $this->waitForText('crm-notification-container', 'Selected financial type account has been deleted.');
76e86fd8 92
6a488035
TO
93 //edit financial type
94 $financialType['oldname'] = $financialType['name'];
92fcb95f 95 $financialType['name'] = 'Edited FinancialType ' . substr(sha1(rand()), 0, 4);
6c6e6187
TO
96 $financialType['is_deductible'] = TRUE;
97 $financialType['is_reserved'] = FALSE;
98 $this->addeditFinancialType($financialType, 'Edit');
6a488035 99 //delete financialtype
6c6e6187 100 $this->addeditFinancialType($financialType, 'Delete');
6a488035 101 }
232624b1 102}