From a574d20bea677a8b92a755c93cd01c5f1a78ade8 Mon Sep 17 00:00:00 2001 From: Tony Hegyes Date: Sun, 1 Nov 2026 11:06:38 +0100 Subject: [PATCH] Test the underscore include skip with an include the row writes The boot row asserted that includes/_disabled-example.php never loads, but the scaffold removes that file, so in every plugin made from the template the row passed even with the loader's underscore check removed. The row writes an underscore-prefixed include defining a constant and checks in a fresh request, which must exit cleanly, that the plugin booted and the constant stayed undefined; it fails once the loader's check is removed. The fresh request comes from RunsRequestsTrait in tests/Support, which PartialDeployTest's helper moves to. Assisted-by: Claude Code:claude-opus-5-5 --- tests/Integration/PartialDeployTest.php | 17 +++-------------- tests/Integration/PluginBootTest.php | 13 ++++++++++++- tests/Support/RunsRequestsTrait.php | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 tests/Support/RunsRequestsTrait.php diff --git a/tests/Integration/PartialDeployTest.php b/tests/Integration/PartialDeployTest.php index 132aa70..5e04219 100644 --- a/tests/Integration/PartialDeployTest.php +++ b/tests/Integration/PartialDeployTest.php @@ -3,12 +3,15 @@ namespace DeepWebSolutions\PluginTemplate\Tests\Integration; use DeepWebSolutions\PluginTemplate\Scoped\DeepWebSolutions\Framework\Core\Uninstall\Uninstaller; +use DeepWebSolutions\PluginTemplate\Tests\Support\RunsRequestsTrait; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; #[CoversNothing] final class PartialDeployTest extends TestCase { + use RunsRequestsTrait; + public function test_a_missing_blocks_manifest_shows_the_build_notice_and_loads_nothing_built(): void { $manifest = \dirname( DWS_TPL_FILE ) . '/blocks/build/blocks-manifest.php'; \rename( $manifest, "$manifest.hidden" ); @@ -83,18 +86,4 @@ static function ( string $class_name ): void { \unlink( $log ); update_option( DWS_TPL_OPTION_DELETE_DATA, 'no' ); } - - /** - * @return array{status: int, output: string, last: string} - */ - protected static function request( string $php ): array { - \exec( 'wp --path=' . \escapeshellarg( ABSPATH ) . ' eval ' . \escapeshellarg( $php ) . ' 2>&1', $output, $status ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec -- Each row needs a fresh request that loads the plugin. - $output = \array_values( \array_filter( $output, static fn ( string $line ): bool => '' !== \trim( $line ) ) ); - - return array( - 'status' => $status, - 'output' => \implode( "\n", $output ), - 'last' => (string) \end( $output ), - ); - } } diff --git a/tests/Integration/PluginBootTest.php b/tests/Integration/PluginBootTest.php index 5a01d44..b389f5a 100644 --- a/tests/Integration/PluginBootTest.php +++ b/tests/Integration/PluginBootTest.php @@ -9,11 +9,14 @@ use DeepWebSolutions\PluginTemplate\Scoped\DeepWebSolutions\Framework\Core\Migration\MigrationRunner; use DeepWebSolutions\PluginTemplate\Scoped\DeepWebSolutions\Framework\Core\Scheduling\Scheduler; use DeepWebSolutions\PluginTemplate\Settings; +use DeepWebSolutions\PluginTemplate\Tests\Support\RunsRequestsTrait; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\TestCase; #[CoversNothing] final class PluginBootTest extends TestCase { + use RunsRequestsTrait; + public function test_the_plugin_boots_with_the_greeting_gated_off_until_a_site_switches_it_on(): void { $plugin = dws_tpl_plugin(); @@ -26,7 +29,15 @@ public function test_the_entry_loads_every_include_but_those_whose_names_start_w $includes = \dirname( DWS_TPL_FILE ) . '/includes/'; self::assertContains( $includes . 'index.php', \get_included_files() ); - self::assertNotContains( $includes . '_disabled-example.php', \get_included_files() ); + self::assertIsInt( \file_put_contents( $includes . '_skipped-include.php', "&1', $output, $status ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec -- Each row needs a fresh request that loads the plugin. + $output = \array_values( \array_filter( $output, static fn ( string $line ): bool => '' !== \trim( $line ) ) ); + + return array( + 'status' => $status, + 'output' => \implode( "\n", $output ), + 'last' => (string) \end( $output ), + ); + } +}