Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] dev/core#1621 Extend unit tests to ensure that entity financial account is co… #16639

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public function setUp() {
}

public function teardown() {
global $dbLocale;
if ($dbLocale) {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
}
$this->financialAccountDelete('Donations');
}

Expand Down Expand Up @@ -88,10 +92,29 @@ public function testSetIsActive() {
$this->assertEquals($isActive, 0, 'Verify financial types is_active.');
}

/**
* Data provider for testGitLabIssue1108
*
* First we run it without multiLingual mode, then with.
*
* This is because we test table names, which may have been translated in a
* multiLingual context.
*
*/
public function multiLingual() {
return [[0], [1]];
}

/**
* Check method del()
*
* @dataProvider multiLingual
*/
public function testDel() {
public function testDel($isMultiLingual) {
if ($isMultiLingual) {
$this->enableMultilingual();
CRM_Core_I18n_Schema::addLocale('fr_FR', 'en_US');
}
$params = [
'name' => 'Donations',
'is_deductible' => 0,
Expand All @@ -100,10 +123,20 @@ public function testDel() {
$ids = [];
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);

if ($isMultiLingual) {
global $dbLocale;
$dbLocale = '_fr_FR';
}
CRM_Financial_BAO_FinancialType::del($financialType->id);
$params = ['id' => $financialType->id];
$result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults);
$this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
$results = CRM_Core_DAO::executeQuery("SELECT * FROM civicrm_entity_financial_account WHERE entity_id = %1", [1 => [$financialType->id, 'Positive']])->fetchAll();
$this->assertEquals(empty($results), TRUE, 'Assert related entity financial account has been deleted as well');
if ($isMultiLingual) {
global $dbLocale;
$dbLocale = '_en_US';
}
}

/**
Expand Down