SettingStyleTest - Enforce tighter naming standards (going forward)
authorTim Otten <totten@civicrm.org>
Thu, 4 Aug 2022 07:15:14 +0000 (00:15 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 4 Aug 2022 07:26:05 +0000 (00:26 -0700)
tests/phpunit/Civi/Core/SettingsStyleTest.php

index 6d594a9e959956f5bbd36b169f72d0f07b403640..0098c5a8d9112a3b0ab77719c45bea876d7eb581 100644 (file)
@@ -34,6 +34,12 @@ class SettingsStyleTest extends \CiviUnitTestCase {
       $assert($key, $key === $spec['name'], 'Should have matching name');
       $type = $spec['type'] ?? 'UNKNOWN';
       $assert($key, in_array($type, $validTypes), 'Should have known type. Found: ' . $type);
+      if (version_compare($spec['add'], '5.53', '>=')) {
+        $assert($key, preg_match(';^[a-z0-9]+(_[a-z0-9]+)+$;', $key), 'In 5.53+, names should use snake_case with a group/subsystem prefix.');
+      }
+      else {
+        $assert($key, preg_match(';^[a-z][a-zA-Z0-9_]+$;', $key), 'In 4.1-5.52, names should snake_case or lowerCamelCase.');
+      }
     }
     $this->assertEquals([], $errors);
   }