From d84d2cb587345541ef1483e36b8dfeba30d89d8b Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Fri, 18 Jun 2021 14:06:08 -0400 Subject: [PATCH] test lots of roles on cases --- tests/phpunit/CRM/Case/BAO/CaseTest.php | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/phpunit/CRM/Case/BAO/CaseTest.php b/tests/phpunit/CRM/Case/BAO/CaseTest.php index 588162c30d..a8e4c1d280 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTest.php @@ -1201,4 +1201,35 @@ class CRM_Case_BAO_CaseTest extends CiviUnitTestCase { $this->assertArrayHasKey($caseId, CRM_Case_BAO_Case::getCases(FALSE, ['type' => 'any'])); } + /** + * Test a high number of assigned case roles. + */ + public function testGoingTo11() { + $loggedInUser = $this->createLoggedInUser(); + $individual = $this->individualCreate(); + $caseObj = $this->createCase($individual, $loggedInUser); + $caseId = $caseObj->id; + + // Create lots of assigned roles + for ($i = 1; $i <= 30; $i++) { + // create a new type + $relationship_type_id = $this->callAPISuccess('RelationshipType', 'create', [ + 'name_a_b' => "has as Wizard level $i", + 'name_b_a' => "is Wizard level $i for", + ])['id']; + + // Now make a new person and give them the role + $contact_id = $this->individualCreate([], 0, TRUE); + $this->callAPISuccess('Relationship', 'create', [ + 'case_id' => $caseId, + 'contact_id_a' => $individual, + 'contact_id_b' => $contact_id, + 'relationship_type_id' => $relationship_type_id, + ]); + } + + // Note the stock case type adds a manager role for the logged in user so it's 31 not 30. + $this->assertCount(31, CRM_Case_BAO_Case::getCaseRoles($individual, $caseId), 'Why not just make ten louder?'); + } + } -- 2.25.1