StubsStructureValidatorTest
class StubsStructureValidatorTest extends TestCase (View source)
Validates the structural integrity of the stubs directory layout.
Ensures every top-level stubs directory is explicitly registered in StubCategory::getDirectories() so that new extension folders are never silently ignored by data providers and category-based filters.
Methods
Provides each top-level stubs directory as a separate test case.
Assert that every top-level stubs directory is present in StubCategory::getDirectories().
Assert that tests/Framework/Tools/generate-stubs-map.php generates a valid PhpStormStubsMap to the project root when called without arguments.
Assert that PhpStormStubsMap.php in the project root is up to date with the current stubs.
Details
static iterable
stubsDirectoryProvider()
Provides each top-level stubs directory as a separate test case.
Uses the active stubs provider so local reference material is not treated as stubs.
void
checkStubsDirectoriesExistsInMap(string $directoryName)
Assert that every top-level stubs directory is present in StubCategory::getDirectories().
When a new extension directory is added to the stubs root it must also be registered in the appropriate StubCategory (CORE, BUNDLED, EXTERNAL, or PECL) so that category-based data providers include it correctly.
void
checkGenerateStubsMapScript()
Assert that tests/Framework/Tools/generate-stubs-map.php generates a valid PhpStormStubsMap to the project root when called without arguments.
Verifies:
- The generator script exists.
- PhpStormStubsMap.php exists in the project root.
- The default output path baked into the script resolves to the project root.
- Running the script exits cleanly (exit code 0).
- The generated output has the expected PHP structure (namespace, class, array constants).
- All paths in the map are relative — no absolute filesystem paths.
void
checkStubMapIsUpToDate()
Assert that PhpStormStubsMap.php in the project root is up to date with the current stubs.
Generates a fresh map into a temporary file using generate-stubs-map.php and compares its content byte-for-byte against the committed PhpStormStubsMap.php. Any discrepancy means a stub file was added, removed, or renamed without regenerating the map.
Fix: run php tests/Framework/Tools/generate-stubs-map.php from the project root.