diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 38828c425716..0365d2a09153 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -111,13 +111,6 @@ public function setUp() { 'Payment', 'Order', ]; - $this->onlyIDNonZeroCount['get'] = [ - 'ActivityType', - 'Entity', - 'Domain', - 'Setting', - 'User', - ]; $this->deprecatedAPI = ['Location', 'ActivityType', 'SurveyRespondant']; $this->deletableTestObjects = []; } @@ -128,6 +121,7 @@ public function tearDown() { CRM_Core_DAO::deleteTestObjects($entityName, ['id' => $entityID]); } } + $this->deletableTestObjects = NULL; } /** @@ -928,7 +922,7 @@ public function testAcceptsOnlyID_get($Entity) { // just to get a clearer message in the log $this->assertEquals("only id should be enough", $result['error_message']); } - if (!in_array($Entity, $this->onlyIDNonZeroCount['get'])) { + if (!in_array($Entity, $this->getOnlyIDNonZeroCount(), TRUE)) { $this->assertEquals(0, $result['count']); } } @@ -987,7 +981,7 @@ public function testByID_get($entityName) { } $baos = $this->getMockableBAOObjects($entityName); - list($baoObj1, $baoObj2) = $baos; + [$baoObj1, $baoObj2] = $baos; // fetch first by ID $result = $this->callAPISuccess($entityName, 'get', [ @@ -1209,7 +1203,7 @@ public function testNonExistantID_get($Entity) { $this->assertArrayHasKey('version', $result); $this->assertEquals(3, $result['version']); - if (!in_array($Entity, $this->onlyIDNonZeroCount['get'])) { + if (!in_array($Entity, $this->getOnlyIDNonZeroCount(), TRUE)) { $this->assertEquals(0, $result['count']); } } @@ -1598,7 +1592,7 @@ public function testByID_delete($entityName) { $startCount = $this->callAPISuccess($entityName, 'getcount', []); $createcount = 2; $baos = $this->getMockableBAOObjects($entityName, $createcount); - list($baoObj1, $baoObj2) = $baos; + [$baoObj1, $baoObj2] = $baos; // make sure exactly 2 exist $result = $this->callAPISuccess($entityName, 'getcount', [], @@ -1837,4 +1831,19 @@ public function testEncodeWrite() { ]); } + /** + * Get entities that have non-zero counts already. + * + * @return string[] + */ + protected function getOnlyIDNonZeroCount(): array { + return [ + 'ActivityType', + 'Entity', + 'Domain', + 'Setting', + 'User', + ]; + } + }