From 4f92030f908cfa78ae0c467cdc1ace396f6aa656 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 19 Oct 2019 13:49:17 +1300 Subject: [PATCH] dev/core#1321 [test] add unit test to demonstrate behaviour --- tests/phpunit/api/v3/GroupTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index 26caaeebf8..8095bf2bb8 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -273,6 +273,22 @@ class api_v3_GroupTest extends CiviUnitTestCase { $this->assertAPIArrayComparison([2, 1], $groupType); } + /** + * Test / demonstrate behaviour when attempting to filter by group_type. + * + * Per https://lab.civicrm.org/dev/core/issues/1321 the group_type filter is deceptive + * - it only filters on exact match not 'is one of'. + * + * @throws \CRM_Core_Exception + */ + public function testGroupWithGroupTypeFilter() { + $this->groupCreate(['group_type' => ['Access Control'], 'name' => 'access_list', 'title' => 'access list']); + $this->groupCreate(['group_type' => ['Mailing List'], 'name' => 'mailing_list', 'title' => 'mailing list']); + $this->groupCreate(['group_type' => ['Access Control', 'Mailing List'], 'name' => 'group', 'title' => 'group']); + $group = $this->callAPISuccessGetSingle('Group', ['return' => 'id,title,group_type', 'group_type' => 'Mailing List']); + $this->assertEquals('mailing list', $group['title']); + } + /** * @param int $version * -- 2.25.1