Skip to content

Commit

Permalink
Merge pull request #20288 from demeritcowboy/fintypeaccount
Browse files Browse the repository at this point in the history
[NFC/TEST] - Add unit test enforcing automatic chaining for financial type/account creation via api
  • Loading branch information
seamuslee001 authored May 13, 2021
2 parents 80afb2e + 1bc3b35 commit 3a86f5a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/phpunit/api/v3/FinancialTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,26 @@ public function testCreateUpdateFinancialTypeCustomField(): void {
}
}

/**
* Enforce the creation of an associated financial account when a financial
* type is created through the api.
* @dataProvider versionThreeAndFour
*/
public function testAssociatedFinancialAccountGetsCreated($apiVersion) {
$this->callAPISuccess('FinancialType', 'create', [
'version' => $apiVersion,
'name' => 'Lottery Tickets',
'is_deductible' => FALSE,
'is_reserved' => FALSE,
'is_active' => TRUE,
]);
// There should be an account (as opposed to type) with the same name that gets autocreated.
$result = $this->callAPISuccess('FinancialAccount', 'getsingle', [
'version' => $apiVersion,
'name' => 'Lottery Tickets',
]);
$this->assertNotEmpty($result['id'], 'Financial account with same name as type did not get created.');
$this->assertEquals('INC', $result['account_type_code'], 'Financial account created is not an income account.');
}

}

0 comments on commit 3a86f5a

Please sign in to comment.