From 8dc85687b0b6a1a545a4fdffa9c940fd108a5982 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Thu, 10 Sep 2026 21:36:38 -0700 Subject: [PATCH 1/2] Add descriptions to composer scripts --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index c5920cc3dc..b9f22a9ac6 100644 --- a/composer.json +++ b/composer.json @@ -40,5 +40,12 @@ "test": "phpunit --no-coverage", "test-integration": "phpunit --no-coverage --testsuite integration", "test-unit": "phpunit --no-coverage --testsuite unit" + }, + "scripts-descriptions": { + "lint": "Check changed PHP files with PHP-CS-Fixer. Does not work on Windows!", + "lint-fix": "Fix coding standards in changed PHP files with PHP-CS-Fixer. Does not work on Windows!", + "test": "Run the PHPUnit test suite.", + "test-integration": "Run the PHPUnit integration test suite.", + "test-unit": "Run the PHPUnit unit test suite." } } From de7c4abd70b3f6973f3dc5d7a365171e452870d1 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Thu, 10 Sep 2026 22:34:28 -0700 Subject: [PATCH 2/2] Add an auto review test suite --- .github/workflows/php.yml | 3 + phpunit.xml.dist | 3 + tests/AutoReview/ComposerFileTest.php | 94 +++++++++++++++++++++++++++ tests/AutoReview/index.php | 8 +++ 4 files changed, 108 insertions(+) create mode 100644 tests/AutoReview/ComposerFileTest.php create mode 100644 tests/AutoReview/index.php diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 00b812fd28..c043a2d84e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -37,6 +37,9 @@ jobs: php ./vendor/simplemachines/build-tools/check-smf-index.php php ./vendor/simplemachines/build-tools/check-version.php + - name: Running the auto review test suite + run: vendor/bin/phpunit --testsuite auto-review + lint: runs-on: ubuntu-latest strategy: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 720240fd3c..2401f66375 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,6 +8,9 @@ failOnRisky="true" failOnWarning="true"> + + tests/AutoReview + tests/Unit diff --git a/tests/AutoReview/ComposerFileTest.php b/tests/AutoReview/ComposerFileTest.php new file mode 100644 index 0000000000..a7f9f5b116 --- /dev/null +++ b/tests/AutoReview/ComposerFileTest.php @@ -0,0 +1,94 @@ +readComposerJson(); + + $this->assertArrayHasKey('scripts', $composer_json); + $this->assertArrayHasKey('scripts-descriptions', $composer_json); + + $descriptions = array_keys($composer_json['scripts-descriptions']); + $event_scripts = [ + 'pre-install-cmd', + 'post-install-cmd', + 'pre-update-cmd', + 'post-update-cmd', + 'pre-status-cmd', + 'post-status-cmd', + 'pre-archive-cmd', + 'post-archive-cmd', + 'pre-autoload-dump', + 'post-autoload-dump', + 'post-root-package-install', + 'post-create-project-cmd', + 'pre-operations-exec', + 'pre-package-install', + 'post-package-install', + 'pre-package-update', + 'post-package-update', + 'pre-package-uninstall', + 'post-package-uninstall', + 'init', + 'command', + 'pre-file-download', + 'post-file-download', + 'pre-command-run', + 'pre-pool-create', + ]; + $scripts = array_diff( + array_keys($composer_json['scripts']), + $event_scripts, + ); + + $this->assertSame( + [], + array_diff($scripts, $descriptions), + 'There should be no scripts with missing descriptions.', + ); + + $this->assertSame( + [], + array_diff($descriptions, $scripts), + 'There should be no superfluous descriptions for undefined scripts.', + ); + } + + public function testPlatformPhpVersionSatisfiesPhpRequirement(): void + { + $composer_json = $this->readComposerJson(); + + $this->assertArrayHasKey('require', $composer_json); + $this->assertArrayHasKey('php', $composer_json['require']); + $this->assertArrayHasKey('config', $composer_json); + $this->assertArrayHasKey('platform', $composer_json['config']); + $this->assertArrayHasKey('php', $composer_json['config']['platform']); + + $php_requirement = $composer_json['require']['php']; + $platform_php = $composer_json['config']['platform']['php']; + + $this->assertTrue( + \Composer\Semver\Semver::satisfies($platform_php, $php_requirement), + "Platform PHP version '{$platform_php}' does not satisfy PHP requirement '{$php_requirement}'.", + ); + } + + /** + * @return array + */ + private function readComposerJson(): array + { + $composer_json_content = (string) file_get_contents(__DIR__ . '/../../composer.json'); + + return json_decode($composer_json_content, true, 512, JSON_THROW_ON_ERROR); + } +} diff --git a/tests/AutoReview/index.php b/tests/AutoReview/index.php new file mode 100644 index 0000000000..2844a3b9e7 --- /dev/null +++ b/tests/AutoReview/index.php @@ -0,0 +1,8 @@ +