From 874f93b252ecff3471eeea8519684279f81ecc1f Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Wed, 22 Apr 2026 08:40:03 +0000 Subject: [PATCH] fix(tests): define PR_CORE_PLUGIN_DIR + trailingslashit in bootstrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP Lint (8.2) failed after the floatval removal surfaced a deeper issue: the autoloader references PR_CORE_PLUGIN_DIR unconditionally, which is defined in the main plugin bootstrap but not loaded by the test runner. Same for trailingslashit (a WP function the autoloader calls). Added constants and a tiny trailingslashit stub to tests/bootstrap.php so plain-php unit runs can load the autoloader and exercise the CPT class. No runtime behavior change — test harness only. --- tests/bootstrap.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3c362d9..c028d53 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -22,6 +22,24 @@ if ( ! defined( 'PR_CORE_VERSION' ) ) { define( 'PR_CORE_VERSION', '0.2.0' ); } +if ( ! defined( 'PR_CORE_PLUGIN_DIR' ) ) { + define( 'PR_CORE_PLUGIN_DIR', realpath( __DIR__ . '/..' ) . '/' ); +} + +if ( ! defined( 'PR_CORE_PLUGIN_URL' ) ) { + define( 'PR_CORE_PLUGIN_URL', 'http://example.test/wp-content/plugins/peptide-repo-core/' ); +} + +if ( ! defined( 'PR_CORE_PLUGIN_FILE' ) ) { + define( 'PR_CORE_PLUGIN_FILE', PR_CORE_PLUGIN_DIR . 'peptide-repo-core.php' ); +} + +if ( ! function_exists( 'trailingslashit' ) ) { + function trailingslashit( string $path ): string { + return rtrim( $path, '/\\' ) . '/'; + } +} + /** * Global harness state. Tests reset this between cases. *