From 155ea29ab0d39be995bd8a6b492240fb194be99f Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 4 Dec 2020 13:41:10 +1300 Subject: [PATCH] Minor cleanup in test class --- .../phpunit/api/v4/Entity/ConformanceTest.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/api/v4/Entity/ConformanceTest.php b/tests/phpunit/api/v4/Entity/ConformanceTest.php index 18fef73a2b..eac1f5f9d5 100644 --- a/tests/phpunit/api/v4/Entity/ConformanceTest.php +++ b/tests/phpunit/api/v4/Entity/ConformanceTest.php @@ -94,7 +94,7 @@ class ConformanceTest extends UnitTestCase { $manual['remove'] = ['CustomValue']; $scanned = []; - $srcDir = dirname(dirname(dirname(dirname(dirname(__DIR__))))); + $srcDir = dirname(__DIR__, 5); foreach ((array) glob("$srcDir/Civi/Api4/*.php") as $name) { $scanned[] = preg_replace('/\.php/', '', basename($name)); } @@ -118,9 +118,12 @@ class ConformanceTest extends UnitTestCase { /** * @param string $entity * Ex: 'Contact' + * * @dataProvider getEntitiesLotech + * + * @throws \API_Exception */ - public function testConformance($entity) { + public function testConformance($entity): void { $entityClass = 'Civi\Api4\\' . $entity; $this->checkEntityInfo($entityClass); @@ -145,7 +148,7 @@ class ConformanceTest extends UnitTestCase { /** * @param \Civi\Api4\Generic\AbstractEntity|string $entityClass */ - protected function checkEntityInfo($entityClass) { + protected function checkEntityInfo($entityClass): void { $info = $entityClass::getInfo(); $this->assertNotEmpty($info['name']); $this->assertNotEmpty($info['title']); @@ -157,6 +160,8 @@ class ConformanceTest extends UnitTestCase { /** * @param \Civi\Api4\Generic\AbstractEntity|string $entityClass * @param string $entity + * + * @throws \API_Exception */ protected function checkFields($entityClass, $entity) { $fields = $entityClass::getFields(FALSE) @@ -174,8 +179,10 @@ class ConformanceTest extends UnitTestCase { * @param \Civi\Api4\Generic\AbstractEntity|string $entityClass * * @return array + * + * @throws \API_Exception */ - protected function checkActions($entityClass) { + protected function checkActions($entityClass): array { $actions = $entityClass::getActions(FALSE) ->execute() ->indexBy('name'); @@ -210,7 +217,7 @@ class ConformanceTest extends UnitTestCase { * @param \Civi\Api4\Generic\AbstractEntity|string $entityClass * @param int $id */ - protected function checkUpdateFailsFromCreate($entityClass, $id) { + protected function checkUpdateFailsFromCreate($entityClass, $id): void { $exceptionThrown = ''; try { $entityClass::create(FALSE) @@ -243,7 +250,7 @@ class ConformanceTest extends UnitTestCase { * @param int $id * @param string $entity */ - protected function checkGetCount($entityClass, $id, $entity) { + protected function checkGetCount($entityClass, $id, $entity): void { $getResult = $entityClass::get(FALSE) ->addWhere('id', '=', $id) ->selectRowCount() -- 2.25.1