mirror of
https://ghproxy.net/https://github.com/fairpm/fair-plugin.git
synced 2026-08-11 14:00:29 +08:00
Six items from the testing plan, now done: 1. install-activate-update.spec.ts (@slow) — full install/activate/update flow via Direct Install tab. Mock server extended with hello-dolly DID fixtures (did-doc + metadata-doc) and zip artifact serving route at /artifacts/*.zip. 2. avatar-upload.spec.ts — profile page rendering, avatar section presence, display name accessibility. Avatar image verification handles Gravatar rate-limiting (at least one loaded = pass). 3. update-error-row.spec.ts — plugins page structure, FAIR error row detection, no JS errors on plugins page. 4. SignatureVerificationIntegrationTest.php — 5 tests running inside Docker WP container. Covers verify_file_signature() (WP 5.2+) with live sodium Ed25519 keys, tampered file rejection, missing-key rejection, wrong-signature rejection, key encoding round-trip. NB: WP 6.4 uses SHA-384 (not SHA-512) for file hashing. 5. Coverage reporting in CI — added dedicated 'coverage' job to phpunit-tests.yml. Runs on push to main/development/release only, uses PHP 8.4 + XDebug, uploads HTML coverage artifact. 6. minMsi threshold — set minMsi=9 (current baseline), minCoveredMsi=90. Updated mock server: - /artifacts/<file.zip> route serves zips from tests/fixtures/zips/ - hello-dolly DID/meta fixtures for browser install flow Updated integration bootstrap: - require wp-admin/includes/file.php for verify_file_signature() Totals: 262 unit (489 assertions), 17 integration (48), 12 HTTP (38), 23 browser (non-slow), 3 browser (@slow). Exit code 0. Signed-off-by: Chuck Adams <chaz@chaz.works>
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Integration test bootstrap — runs inside Docker wp-cli container.
|
|
*
|
|
* Loads WordPress + plugin + composer autoloader directly.
|
|
* Does NOT require the WordPress test suite (WP_UnitTestCase).
|
|
* Tests extend PHPUnit\Framework\TestCase and use real WP APIs.
|
|
*
|
|
* @package FAIR
|
|
*/
|
|
|
|
// Composer autoloader (plugin's vendor directory).
|
|
$plugin_dir = '/var/www/html/wp-content/plugins/fair-plugin';
|
|
$autoloader = "{$plugin_dir}/vendor/autoload.php";
|
|
|
|
if ( ! file_exists( $autoloader ) ) {
|
|
fwrite( STDERR, "Composer autoloader not found at {$autoloader}\n" );
|
|
fwrite( STDERR, "Run 'composer install' in the plugin directory first.\n" );
|
|
exit( 1 );
|
|
}
|
|
|
|
require_once $autoloader;
|
|
|
|
// Load WordPress.
|
|
$_tests_dir = '/var/www/html';
|
|
|
|
if ( ! file_exists( "{$_tests_dir}/wp-load.php" ) ) {
|
|
fwrite( STDERR, "WordPress not found at {$_tests_dir}\n" );
|
|
exit( 1 );
|
|
}
|
|
|
|
// Define constants before WP loads.
|
|
define( 'FAIR_PLC_DIRECTORY_URL', 'http://mock-server:8080' );
|
|
define( 'FAIR_DEFAULT_REPO_DOMAIN', 'mock-server:8080' );
|
|
|
|
// Load WP (but don't send headers — we're in CLI mode).
|
|
$_SERVER['HTTP_HOST'] = 'integration.local';
|
|
define( 'WP_USE_THEMES', false );
|
|
require_once "{$_tests_dir}/wp-load.php";
|
|
|
|
// Load the plugin (already activated, but ensure functions are available).
|
|
require_once "{$plugin_dir}/plugin.php";
|
|
|
|
// verify_file_signature() lives in wp-admin/includes/file.php (not loaded in CLI).
|
|
require_once ABSPATH . 'wp-admin/includes/file.php';
|