From 41e623d5d1d7ba3dae72ceed75095f65c08606d2 Mon Sep 17 00:00:00 2001 From: interlope Date: Sun, 1 Nov 2026 18:41:20 +0100 Subject: [PATCH] Update README and metadata for version 1.1.1; add discovery test for plugin class loading --- README.md | 3 +++ metadata.json | 2 +- plugin.php | 5 +++-- tests/discovery.php | 48 +++++++++++++++++++++++++++++++++++++++++++++ tests/import.php | 5 +++++ 5 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 tests/discovery.php diff --git a/README.md b/README.md index ab259aa..0744682 100644 --- a/README.md +++ b/README.md @@ -130,9 +130,12 @@ No Composer dependencies or YAML extension are required. To run the tests agains ```bash php -l plugin.php php -l importer.php +BLUDIT_ROOT=/path/to/bludit-3.22.0 php tests/discovery.php BLUDIT_ROOT=/path/to/bludit-3.22.0 php tests/import.php ``` +The discovery regression test runs Bludit's real `buildPlugins()` with its real `Plugin` base class. Helper classes are loaded from `init()`, after class discovery, so Bludit does not mistake them for plugins. + Tests use temporary local storage and a fake GitHub transport. They exercise real Bludit page creation/editing, asset rewriting and export round trips, rejected paths, escaped previews, stale metadata/configuration, failed downloads and rollback after a failing page hook. They do not modify a live site or contact GitHub. Optionally exercise a real exported article as a fixture too: diff --git a/metadata.json b/metadata.json index 7804dd5..ee21455 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "author": "spleenftw", "email": "", "website": "https://github.com/Spleenftw/bludit-github-sync", - "version": "1.1.0", + "version": "1.1.1", "releaseDate": "2026-11-01", "license": "MIT", "compatible": "3.22.0", diff --git a/plugin.php b/plugin.php index a7cdeec..445dc8a 100644 --- a/plugin.php +++ b/plugin.php @@ -1,12 +1,13 @@ dbFields = [ 'token' => '', 'owner' => '', diff --git a/tests/discovery.php b/tests/discovery.php new file mode 100644 index 0000000..baf6d0e --- /dev/null +++ b/tests/discovery.php @@ -0,0 +1,48 @@ +\n{}"); +foreach (['filesystem', 'sanitize', 'session', 'log'] as $helper) { require $root . '/bl-kernel/helpers/' . $helper . '.class.php'; } +require $root . '/bl-kernel/abstract/dbjson.class.php'; +require $root . '/bl-kernel/abstract/plugin.class.php'; +$site = new class { public function language() { return 'en'; } }; +$L = new class { public function add($words) {} }; +try { + require $root . '/bl-kernel/boot/rules/60.plugins.php'; + if (array_keys($plugins['all']) !== ['pluginBluditGithub'] || array_keys($pluginsInstalled) !== ['pluginBluditGithub']) { + throw new RuntimeException('A helper was discovered as a plugin or the real plugin was not installed.'); + } + if (!class_exists('BluditGithubImport', false)) { throw new RuntimeException('Import helper was not loaded during initialization.'); } + // Uninstalled plugins are discovered too; loading must also work before installation. + if ($plugins['all']['pluginBluditGithub']->directoryName() !== 'bludit-github') { throw new RuntimeException('Directory identity changed.'); } + echo "PASS: real Bludit 3.x plugin discovery, installed Plugin constructor, metadata and language loading\n"; +} finally { + Filesystem::deleteRecursive($dir); +} diff --git a/tests/import.php b/tests/import.php index 65b378d..7185655 100644 --- a/tests/import.php +++ b/tests/import.php @@ -40,7 +40,11 @@ class Plugin { public function workspace() { global $dir; return $dir . 'workspace/'; } public function post() {} } +$declaredBeforePlugin = get_declared_classes(); require dirname(__DIR__) . '/plugin.php'; +if (array_values(array_diff(get_declared_classes(), $declaredBeforePlugin)) !== ['pluginBluditGithub']) { + throw new RuntimeException('Only the plugin class may be declared during Bludit discovery.'); +} class TestIndex { public $count = 0; public function exists($key) { return in_array($key, ['network', 'uncategorized'], true); } public function reindex() { $this->count++; return true; } } class TestLog { public function add($args) {} } class Theme { @@ -90,6 +94,7 @@ $site = new class { public function sortBy() { return 'date'; } public function $L = new class { public function g($s) { return $s; } public function getunicodeChars() { return []; } public function currentLanguage() { return 'en'; } }; Session::set('username', 'admin'); $plugin = new TestPlugin(); +$plugin->init(); try { // Parser and filesystem boundaries. foreach (['../bad', 'a/b', '', 'x%2fy', 'x\\y'] as $slug) { rejects(function () use ($slug) { BluditGithubImport::slug($slug); }, 'folder name'); }