From 1bc3b3507449eab99ad6e483310b2128bdd18910 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Thu, 13 May 2021 16:22:57 -0400 Subject: [PATCH] add test enforcing automatic chaining for financial type/account create --- tests/phpunit/api/v3/FinancialTypeTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/phpunit/api/v3/FinancialTypeTest.php b/tests/phpunit/api/v3/FinancialTypeTest.php index 0a96e4247a..4b9a653123 100644 --- a/tests/phpunit/api/v3/FinancialTypeTest.php +++ b/tests/phpunit/api/v3/FinancialTypeTest.php @@ -92,4 +92,26 @@ class api_v3_FinancialTypeTest extends CiviUnitTestCase { } } + /** + * 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.'); + } + } -- 2.25.1