Accumulated patterns and anti-patterns from development sessions. Auto-managed by caliber — do not edit manually.
- [gotcha:project]
tests/DirectadminIncTest.phphas atestFunctionCount()that asserts an exact count of functions insrc/directadmin.inc.php(currently 16). Every time you add a function to that file, the test will fail until you updateassertCount(16, ...)to the new total. Runvendor/bin/phpunit --filter testFunctionCountto confirm the count before committing. - [gotcha:project]
tests/PluginTest.phphas atestGetHooksCount()that asserts an exact count of hooks returned byPlugin::getHooks()(currently 6). Adding any entry togetHooks()will break this test until you updateassertCount(6, ...)to the new total. - [pattern:project] PHPUnit tests for
src/directadmin.inc.phpuse static source-scan assertions (assertStringContainsString()onfile_get_contents()) rather than calling functions directly, because most functions depend on MyAdmin globals ($GLOBALS['tf'],DIRECTADMIN_USERNAMEconstant, DB). Onlyget_directadmin_license_types()is safe to call directly in tests — all other functions must be tested via source analysis. - [pattern:project] When adding a new function to
src/directadmin.inc.php, three test updates are always required: (1) add atestYourFunctionIsDefined()source-scan test totests/DirectadminIncTest.php, (2) updatetestFunctionCount()count, (3) optionally add atestYourFunctionParameterSignature()regex test if the signature is load-bearing. - [pattern:project] When adding a new hook to
Plugin::getHooks(), two test updates are always required intests/PluginTest.php: (1) addassertArrayHasKey('licenses.new_event', $hooks), (2) updatetestGetHooksCount()to the new count.