Skip to content
Snippets Groups Projects
Commit 80f293e8 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge branch 'CRM-12470' of git://github.com/pradpnayak/civicrm-core into pradpnayak-CRM-12470

Conflicts:
	CRM/Upgrade/Incremental/sql/4.3.4.mysql.tpl
parents eac4cc70 f17d75bb
No related branches found
No related tags found
No related merge requests found
Showing
with 102 additions and 267 deletions
......@@ -22,3 +22,7 @@ INSERT INTO civicrm_setting
VALUES
({$domainID}, NULL, 1, 'CiviCRM Preferences', 'contact_smart_group_display', '{serialize}1{/serialize}');
-- CRM-12470
UPDATE civicrm_financial_account
SET is_default = 1
WHERE name IN ('{ts escape="sql"}Premiums{/ts}', '{ts escape="sql"}Banking Fees{/ts}', '{ts escape="sql"}Accounts Payable{/ts}', '{ts escape="sql"}Donation{/ts}');
......@@ -57,7 +57,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
$params = array(
'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
'title' => 'Test Contribution Page',
'financial_type_id' => $this->_contributionTypeID,
'financial_type_id' => $this->_contributionTypeID,
'intro_text' => '',
'footer_text' => 'Thanks',
'is_for_organization' => 0,
......@@ -88,7 +88,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
$params = array(
'title' => 'Test Contribution Page',
'financial_type_id' => $this->_contributionTypeID,
'financial_type_id' => $this->_contributionTypeID,
'is_active' => 1,
);
......@@ -96,7 +96,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
$id = $contributionpage->id;
$is_active = 1;
$pageActive = CRM_Contribute_BAO_ContributionPage::setIsActive($id, $is_active);
$this->assertEquals( $pageActive, true, 'Verify financial types record deletion.');
$this->assertEquals($pageActive, true, 'Verify financial types record deletion.');
ContributionPage::delete($contributionpage->id);
}
......@@ -107,7 +107,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
$params = array(
'title' => 'Test Contribution Page',
'financial_type_id' => $this->_contributionTypeID,
'financial_type_id' => $this->_contributionTypeID,
'is_active' => 1,
);
......@@ -118,7 +118,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
$setValues = CRM_Contribute_BAO_ContributionPage::setValues($id, $values);
$this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
$this->assertEquals( $this->_contributionTypeID, $values['financial_type_id'], 'Verify financial types id.');
$this->assertEquals($this->_contributionTypeID, $values['financial_type_id'], 'Verify financial types id.');
$this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
ContributionPage::delete($contributionpage->id);
}
......@@ -130,7 +130,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
$params = array(
'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
'title' => 'Test Contribution Page',
'financial_type_id' => $this->_contributionTypeID,
'financial_type_id' => $this->_contributionTypeID,
'intro_text' => '',
'footer_text' => 'Thanks',
'is_for_organization' => 0,
......@@ -149,7 +149,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
$contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
$copycontributionpage = CRM_Contribute_BAO_ContributionPage::copy($contributionpage->id);
$this->assertEquals( $copycontributionpage->financial_type_id, $this->_contributionTypeID, 'Check for Financial type id.' );
$this->assertEquals($copycontributionpage->financial_type_id, $this->_contributionTypeID, 'Check for Financial type id.');
$this->assertEquals($copycontributionpage->goal_amount, 400, 'Check for goal amount.');
ContributionPage::delete($contributionpage->id);
ContributionPage::delete($copycontributionpage->id);
......
......@@ -29,7 +29,7 @@ require_once 'CiviTest/CiviUnitTestCase.php';
class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase {
function get_info() {
return array(
'name' => 'FinancialAccount BAOs',
'name' => 'FinancialAccount BAOs',
'description' => 'Test all Contribute_BAO_Contribution methods.',
'group' => 'CiviCRM BAO Tests',
);
......@@ -37,6 +37,11 @@ class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase {
function setUp() {
parent::setUp();
$this->organizationCreate();
}
function teardown() {
$this->financialAccountDelete('Donations');
}
/**
......@@ -82,7 +87,7 @@ class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase {
*/
function testSetIsActive() {
$params = array(
'name' => 'testDonations',
'name' => 'Donations',
'is_deductible' => 0,
'is_active' => 1,
);
......@@ -103,7 +108,7 @@ class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase {
*/
function testdel() {
$params = array(
'name' => 'checkDonations',
'name' => 'Donations',
'is_deductible' => 0,
'is_active' => 1,
);
......
......@@ -25,8 +25,6 @@
+--------------------------------------------------------------------+
*/
require_once 'CiviTest/CiviUnitTestCase.php';
require_once 'CRM/Financial/DAO/FinancialAccount.php';
require_once 'CRM/Financial/BAO/FinancialAccount.php';
class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
......@@ -40,6 +38,11 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
function setUp() {
parent::setUp();
$this->organizationCreate();
}
function teardown() {
$this->financialAccountDelete('Donations');
}
/**
......@@ -70,7 +73,7 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
*/
function testRetrieve() {
$params = array(
'name' => 'Donations_1',
'name' => 'Donations',
'is_deductible' => 0,
'is_active' => 1,
);
......@@ -79,7 +82,7 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
$result = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults);
$this->assertEquals($result->name, 'Donations_1', 'Verify financial type name.');
$this->assertEquals($result->name, 'Donations', 'Verify financial type name.');
}
/**
......@@ -87,7 +90,7 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
*/
function testSetIsActive() {
$params = array(
'name' => 'testDonations',
'name' => 'Donations',
'is_deductible' => 0,
'is_active' => 1,
);
......@@ -111,7 +114,7 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
*/
function testdel() {
$params = array(
'name' => 'checkDonations',
'name' => 'Donations',
'is_deductible' => 0,
'is_active' => 1,
);
......@@ -129,25 +132,15 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
*/
function testGetAccountingCode() {
$params = array(
'name' => 'TestFinancialAccount',
'accounting_code' => 4800,
'is_deductible' => 0,
'name' => 'Donations',
'is_active' => 1,
'is_reserved' => 0,
);
$ids = array();
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
$financialParams = array(
'entity_table' => 'civicrm_financial_type',
'entity_id' => $financialType->id,
'account_relationship' => $relationTypeId,
'financial_account_id' => $financialAccount->id,
);
CRM_Financial_BAO_FinancialTypeAccount::add($financialParams, $ids);
$financialAccountid = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', 'Donations', 'id', 'name');
CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccountid, 'accounting_code', '4800');
$accountingCode = CRM_Financial_BAO_FinancialAccount::getAccountingCode($financialType->id);
$this->assertEquals( $accountingCode, 4800, 'Verify accounting code.');
}
......
......@@ -25,22 +25,20 @@
+--------------------------------------------------------------------+
*/
require_once 'CiviTest/CiviUnitTestCase.php';
require_once 'CRM/Financial/DAO/FinancialAccount.php';
require_once 'CRM/Financial/BAO/FinancialAccount.php';
require_once 'CRM/Financial/BAO/FinancialTypeAccount.php';
class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
function get_info() {
return array(
'name' => 'FinancialTypeAccount BAOs',
'name' => 'FinancialTypeAccount BAOs',
'description' => 'Test all Contribute_BAO_Contribution methods.',
'group' => 'CiviCRM BAO Tests',
'group' => 'CiviCRM BAO Tests',
);
}
function setUp() {
parent::setUp();
$this->organizationCreate();
}
/**
......@@ -58,6 +56,7 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
$ids = array();
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$params['name'] = 'test_financialType1';
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
$financialParams = array(
......@@ -92,6 +91,7 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
$ids = array();
$defaults = array();
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$params['name'] = 'test_financialType2';
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
$financialParams = array(
......@@ -119,6 +119,7 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
);
$ids = array();
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$params['name'] = 'test_financialType3';
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$financialParams = array(
......@@ -148,20 +149,20 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
);
$ids = array();
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
$financialParams = array(
'entity_table' => 'civicrm_financial_type',
'entity_id' => $financialType->id,
'account_relationship' => $relationTypeId,
$params = array(
'financial_account_id' => $financialAccount->id,
'payment_processor_type_id' => 1,
'domain_id' => 1,
'billing_mode' => 1,
'name' => 'paymentProcessor',
);
$financialAccountType = CRM_Financial_BAO_FinancialTypeAccount::add($financialParams, $ids);
$processor = CRM_Financial_BAO_PaymentProcessor::create($params);
$account = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount(
$financialAccountType->entity_id,
$financialAccountType->entity_table
$processor->id,
'civicrm_payment_processor'
);
$this->assertEquals( $account, 'TestFinancialAccount', 'Verify Financial Account Name');
$this->assertEquals($account, 'TestFinancialAccount', 'Verify Financial Account Name');
}
/**
......
......@@ -25,16 +25,14 @@
+--------------------------------------------------------------------+
*/
require_once 'CiviTest/CiviUnitTestCase.php';
require_once 'CRM/Financial/DAO/FinancialAccount.php';
require_once 'CRM/Financial/BAO/FinancialAccount.php';
class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
function get_info() {
return array(
'name' => 'FinancialType BAOs',
'name' => 'FinancialType BAOs',
'description' => 'Test all Contribute_BAO_Contribution methods.',
'group' => 'CiviCRM BAO Tests',
'group' => 'CiviCRM BAO Tests',
);
}
......@@ -42,6 +40,10 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
parent::setUp();
}
function teardown() {
$this->financialAccountDelete('Donations');
}
/**
* check method add()
*/
......@@ -80,7 +82,7 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
$defaults = array();
$result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults);
$this->assertEquals( $result->name, 'Donations', 'Verify Name for Financial Type');
$this->assertEquals($result->name, 'Donations', 'Verify Name for Financial Type');
}
/**
......@@ -88,14 +90,14 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
*/
function testSetIsActive() {
$params = array(
'name' => 'testDonations',
'name' => 'Donations',
'is_deductible' => 0,
'is_active' => 1,
);
$ids = array();
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$result = CRM_Financial_BAO_FinancialType::setIsActive($financialType->id, 0);
$this->assertEquals( $result, true , 'Verify financial type record updation for is_active.');
$this->assertEquals($result, true , 'Verify financial type record updation for is_active.');
$isActive = $this->assertDBNotNull(
'CRM_Financial_DAO_FinancialType',
$financialType->id ,
......@@ -103,7 +105,7 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
'id',
'Database check on updated for financial type is_active.'
);
$this->assertEquals( $isActive, 0, 'Verify financial types is_active.');
$this->assertEquals($isActive, 0, 'Verify financial types is_active.');
}
/**
......@@ -111,7 +113,7 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
*/
function testDel() {
$params = array(
'name' => 'checkDonations',
'name' => 'Donations',
'is_deductible' => 0,
'is_active' => 1,
);
......@@ -119,8 +121,8 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
CRM_Financial_BAO_FinancialType::del($financialType->id);
$params = array('id' => $financialType->id );
$params = array('id' => $financialType->id);
$result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults);
$this->assertEquals( empty($result), true, 'Verify financial types record deletion.');
$this->assertEquals(empty($result), true, 'Verify financial types record deletion.');
}
}
\ No newline at end of file
......@@ -1649,7 +1649,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
$this->click('_qf_FinancialType_next');
$this->waitForPageToLoad($this->getTimeoutMsec());
if ($option == 'new') {
$text = "The financial type '{$financialType['name']}' has been added. You can add Financial Accounts to this Financial Type now.";
$text = "Your Financial '{$financialType['name']}' Type has been created, along with a corresponding income account '{$financialType['name']}'. That income account, along with standard financial accounts 'Accounts Receivable', 'Banking Fees' and 'Premiums' have been linked to the financial type. You may edit or replace those relationships here.";
}
else {
$text = "The financial type '{$financialType['name']}' has been saved.";
......@@ -1702,63 +1702,6 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
}
}
function _testAddFinancialType() {
// Add new Financial Account
$orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
$financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
$financialAccountDescription = "{$financialAccountTitle} Description";
$accountingCode = 1033;
$financialAccountType = 'Revenue'; //Asset Revenue
$taxDeductible = FALSE;
$isActive = FALSE;
$isTax = TRUE;
$taxRate = 9.99999999;
$isDefault = FALSE;
//Add new organisation
if ($orgName) {
$this->webtestAddOrganization($orgName);
}
$this->_testAddFinancialAccount(
$financialAccountTitle,
$financialAccountDescription,
$accountingCode,
$orgName,
$financialAccountType,
$taxDeductible,
$isActive,
$isTax,
$taxRate,
$isDefault
);
$this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[8]/span/a[text()='Edit']");
//Add new Financial Type
$financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4);
$financialType['is_deductible'] = TRUE;
$financialType['is_reserved'] = FALSE;
$this->addeditFinancialType($financialType);
$accountRelationship = "Income Account is"; //Asset Account - of Income Account is
$expected[] = array(
'financial_account' => $financialAccountTitle,
'account_relationship' => $accountRelationship
);
$this->select('account_relationship', "label={$accountRelationship}");
// Because it tends to cause problems, all uses of sleep() must be justified in comments
// Sleep should never be used for wait for anything to load from the server
// Justification for this instance: FIXME
sleep(2);
$this->select('financial_account_id', "label={$financialAccountTitle}");
$this->click('_qf_FinancialTypeAccount_next');
$this->waitForPageToLoad($this->getTimeoutMsec());
$text = 'The financial type Account has been saved.';
$this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
return $financialType['name'];
}
function addPremium($name, $sku, $amount, $price, $cost, $financialType) {
$this->waitForElementPresent("_qf_ManagePremiums_upload-bottom");
$this->type("name", $name);
......
......@@ -2305,6 +2305,17 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' )
$this->origExtensionSystem = NULL;
}
}
function financialAccountDelete($name) {
$financialAccount = new CRM_Financial_DAO_FinancialAccount();
$financialAccount->name = $name;
if($financialAccount->find(TRUE)) {
$entityFinancialType = new CRM_Financial_DAO_EntityFinancialAccount();
$entityFinancialType->financial_account_id = $financialAccount->id;
$entityFinancialType->delete();
$financialAccount->delete();
}
}
}
function CiviUnitTestCase_fatalErrorHandler($message) {
......
......@@ -362,16 +362,8 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase {
'is_deductible' => FALSE,
);
$this->addeditFinancialType($financialType);
$this->select('account_relationship', 'label=Income Account is');
$this->select('financial_account_id', 'label=Discounts');
$this->click('_qf_FinancialTypeAccount_next-botttom');
$this->waitForPageToLoad($this->getTimeoutMsec());
$financialType['name'] = $financialTypeName2;
$this->addeditFinancialType($financialType);
$this->select('account_relationship', 'label=Income Account is');
$this->select('financial_account_id', 'label=Discounts');
$this->click('_qf_FinancialTypeAccount_next-botttom');
$this->waitForPageToLoad($this->getTimeoutMsec());
//create 6 contribution
$this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", "_qf_Contribution_upload");
for ($i = 1; $i <= 6; $i++) {
......
......@@ -163,58 +163,11 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase {
}
function _testAddFinancialType() {
// Add new Financial Account
$orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
$financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
$financialAccountDescription = "{$financialAccountTitle} Description";
$accountingCode = 1033;
$financialAccountType = 'Revenue';
$taxDeductible = FALSE;
$isActive = FALSE;
$isTax = TRUE;
$taxRate = 9;
$isDefault = FALSE;
//Add new organisation
if($orgName) {
$this->webtestAddOrganization($orgName);
}
$this->_testAddFinancialAccount($financialAccountTitle,
$financialAccountDescription,
$accountingCode,
$orgName,
$financialAccountType,
$taxDeductible,
$isActive,
$isTax,
$taxRate,
$isDefault
);
$this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
//Add new Financial Type
$financialType['name'] = 'FinancialType '.substr(sha1(rand()), 0, 4);
$financialType['is_deductible'] = TRUE;
$financialType['is_reserved'] = FALSE;
$this->addeditFinancialType($financialType);
$accountRelationship = "Income Account is";
$expected[] = array('financial_account' => $financialAccountTitle,
'account_relationship' => $accountRelationship
);
$this->select('account_relationship', "label={$accountRelationship}");
// Because it tends to cause problems, all uses of sleep() must be justified in comments
// Sleep should never be used for wait for anything to load from the server
// Justification for this instance: FIXME
sleep(2);
$this->select('financial_account_id', "label={$financialAccountTitle}");
$this->click('_qf_FinancialTypeAccount_next');
$this->waitForPageToLoad($this->getTimeoutMsec());
$text = 'The financial type Account has been saved.';
$this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
return $financialType['name'];
}
......
......@@ -121,12 +121,11 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
'is_deductible' => 1,
);
$this->addeditFinancialType($financialType);
$this->select("account_relationship", "label=Cost of Sales Account is");
$this->select("financial_account_id", "label=$from");
$this->clickLink("_qf_FinancialTypeAccount_next_new-botttom");
$this->clickLink("xpath=//a[@id='newfinancialTypeAccount']");
$this->select("account_relationship", "label=Premiums Inventory Account is");
$this->select("financial_account_id", "label=$to");
$this->clickLink("_qf_FinancialTypeAccount_next-botttom");
$premiumName = 'Premium'.substr(sha1(rand()), 0, 7);
$amount = 500;
$sku = 'SKU';
......@@ -187,18 +186,17 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
$from = 'Premiums';
$to = 'Premiums inventory';
$financialType = array(
'name' => 'Test Financial'.substr(sha1(rand()), 0, 7),
'name' => 'Test Financial' . substr(sha1(rand()), 0, 7),
'is_reserved' => 1,
'is_deductible' => 1,
);
$this->addeditFinancialType($financialType);
$this->select("account_relationship", "label=Cost of Sales Account is");
$this->select("financial_account_id", "label=$from");
$this->clickLink("_qf_FinancialTypeAccount_next_new-botttom");
$this->clickLink("xpath=//a[@id='newfinancialTypeAccount']");
$this->select("account_relationship", "label=Premiums Inventory Account is");
$this->select("financial_account_id", "label=$to");
$this->clickLink("_qf_FinancialTypeAccount_next-botttom");
$premiumName = 'Premium'.substr(sha1(rand()), 0, 7);
$premiumName = 'Premium' . substr(sha1(rand()), 0, 7);
$amount = 500;
$sku = 'SKU';
$price = 300;
......
......@@ -37,102 +37,35 @@ class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase {
// Log in using webtestLogin() method
$this->webtestLogin();
// Add new Financial Account
$orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
$financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
$financialAccountDescription = "{$financialAccountTitle} Description";
$accountingCode = 1033;
$financialAccountType = 'Revenue';
$taxDeductible = FALSE;
$isActive = FALSE;
$isTax = TRUE;
$taxRate = 5.20;
$isDefault = FALSE;
//Add new organisation
if ($orgName) {
$this->webtestAddOrganization($orgName);
}
$this->_testAddFinancialAccount(
$financialAccountTitle,
$financialAccountDescription,
$accountingCode,
$orgName,
$financialAccountType,
$taxDeductible,
$isActive,
$isTax,
$taxRate,
$isDefault
);
$this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
$this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom');
//Varify Data after Adding new Financial Account
$verifyData = array(
'name' => $financialAccountTitle,
'description' => $financialAccountDescription,
'accounting_code' => $accountingCode,
'contact_name' => $orgName,
'tax_rate' => $taxRate,
'is_tax' => 'on',
'is_deductible' => 'off',
'is_default' => 'off',
);
$this->_assertFinancialAccount($verifyData);
$verifySelectFieldData = array(
'financial_account_type_id' => $financialAccountType,
);
$this->_assertSelectVerify($verifySelectFieldData);
$this->click('_qf_FinancialAccount_cancel-botttom');
$this->waitForPageToLoad($this->getTimeoutMsec());
//Add new Financial Type
$financialType['name'] = 'FinancialType '.substr(sha1(rand()), 0, 4);
$financialType['is_deductible'] = true;
$financialType['is_reserved'] = false;
$this->addeditFinancialType($financialType);
$accountRelationship = "Income Account is";
$expected[] = array(
'financial_account' => $financialAccountTitle,
'account_relationship' => $accountRelationship
);
$this->select('account_relationship', "label={$accountRelationship}");
$this->select('financial_account_id', "label={$financialAccountTitle}");
$this->click('_qf_FinancialTypeAccount_next_new');
$this->waitForPageToLoad($this->getTimeoutMsec());
$text = 'The financial type Account has been saved.';
$this->waitForText('crm-notification-container', $text);
$text = 'You can add another Financial Account Type.';
$this->waitForText('crm-notification-container', $text);
$accountRelationship = 'Expense Account is';
$expected[] = array(
'financial_account' => 'Banking Fees',
'account_relationship' => $accountRelationship
$expected = array(
array(
'financial_account' => $financialType['name'],
'account_relationship' => "Income Account is",
),
array(
'financial_account' => 'Banking Fees',
'account_relationship' => 'Expense Account is',
),
array(
'financial_account' => 'Accounts Receivable',
'account_relationship' => 'Accounts Receivable Account is',
),
array(
'financial_account' => 'Premiums',
'account_relationship' => 'Cost of Sales Account is',
),
);
$this->select('account_relationship', "label={$accountRelationship}");
$this->select('financial_account_id', "label=Banking Fees");
$this->click('_qf_FinancialTypeAccount_next');
$this->waitForElementPresent('newfinancialTypeAccount');
$text = 'The financial type Account has been saved.';
$this->waitForText('crm-notification-container', $text);
foreach ($expected as $value => $label) {
$this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='$label[financial_account]']/../td[1]", preg_quote($label['account_relationship']));
}
$this->openCiviPage('admin/financial/financialType', 'reset=1', 'newFinancialType');
$this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[3]", $financialAccountTitle. ',Banking Fees');
$this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[3]", 'Accounts Receivable,Banking Fees,Premiums,' . $financialType['name']);
$this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span/a[text()='Accounts']");
$this->waitForElementPresent('newfinancialTypeAccount');
$this->click("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Banking Fees']/../td[7]/span/a[text()='Edit']");
......@@ -142,12 +75,12 @@ class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase {
// Sleep should never be used for wait for anything to load from the server
// Justification for this instance: FIXME
sleep(1);
$this->select('account_relationship', "label=Accounts Receivable Account is");
$this->select('financial_account_id', "label=Accounts Receivable");
$this->select('account_relationship', "label=Premiums Inventory Account is");
$this->select('financial_account_id', "label=Premiums inventory");
$this->click('_qf_FinancialTypeAccount_next');
$this->waitForElementPresent("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Accounts Receivable']/../td[7]/span/a[text()='Edit']");
$this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Accounts Receivable']/../td[1]", preg_quote('Accounts Receivable Account is'));
$this->clickLink("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Accounts Receivable']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom');
$this->waitForElementPresent("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Edit']");
$this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[1]", preg_quote('Premiums Inventory Account is'));
$this->clickLink("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom');
$this->click('_qf_FinancialTypeAccount_next-botttom');
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForText('crm-notification-container', 'Selected financial type account has been deleted.');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment