dca134b5b6
- Delete the HPCT importer (no caller left after core dropped HPCT in PR-020c) and its bootstrap/alias/test-bootstrap entries - Conflict guard notice, log line and HivePress admin tab no longer point to the never-existing `wp wpdo hivepress migrate-from-hpct`; they say to deactivate the legacy plugins (their own tables are not imported) - Verify: ConflictGuardTest guard; HP unit 146 / integration 49 OK, bootstrap smoke OK - PR: PR-020d
67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Tests for WPDO_HivePress_Conflict_Guard — legacy hp-* plugin detection.
|
|
*
|
|
* @covers WPDO_HivePress_Conflict_Guard
|
|
*/
|
|
class HivePressConflictGuardTest extends TestCase {
|
|
|
|
protected function setUp(): void {
|
|
WPDO_HivePress_Conflict_Guard::reset_for_tests();
|
|
}
|
|
|
|
public function test_no_conflicts_when_legacy_plugins_absent(): void {
|
|
// Neither HPCT_Core nor HP_Info_Cards are loaded in the test env.
|
|
$conflicts = WPDO_HivePress_Conflict_Guard::detect_conflicts();
|
|
$this->assertSame( array(), $conflicts );
|
|
$this->assertFalse( WPDO_HivePress_Conflict_Guard::has_conflict() );
|
|
}
|
|
|
|
public function test_conflict_detected_when_hpct_const_defined(): void {
|
|
// Simulate hp-custom-tables presence via constant probe.
|
|
if ( ! defined( 'HPCT_VERSION' ) ) {
|
|
define( 'HPCT_VERSION', '1.0.0' );
|
|
}
|
|
WPDO_HivePress_Conflict_Guard::reset_for_tests();
|
|
$conflicts = WPDO_HivePress_Conflict_Guard::detect_conflicts();
|
|
$this->assertContains( 'hp-custom-tables', $conflicts );
|
|
$this->assertTrue( WPDO_HivePress_Conflict_Guard::has_conflict() );
|
|
}
|
|
|
|
public function test_check_and_warn_safe_when_no_conflicts(): void {
|
|
WPDO_HivePress_Conflict_Guard::reset_for_tests();
|
|
// Should not throw or render anything when clean.
|
|
$this->expectOutputString( '' );
|
|
WPDO_HivePress_Conflict_Guard::check_and_warn();
|
|
}
|
|
|
|
public function test_render_notice_does_nothing_when_not_admin(): void {
|
|
// is_admin() stub returns false by default.
|
|
ob_start();
|
|
WPDO_HivePress_Conflict_Guard::render_notice();
|
|
$out = ob_get_clean();
|
|
$this->assertSame( '', $out );
|
|
}
|
|
|
|
public function test_guidance_does_not_point_to_a_missing_command(): void {
|
|
// There is no HPCT importer: `wp wpdo hivepress migrate-from-hpct` never
|
|
// existed and TMDO_HPCT_Import had no caller once core dropped HPCT.
|
|
$root = dirname( __DIR__, 2 );
|
|
foreach ( array( 'includes/hivepress/class-tmdo-hivepress-conflict-guard.php', 'admin/class-tmdo-admin-hivepress.php' ) as $file ) {
|
|
$this->assertStringNotContainsString( 'migrate-from-hpct', (string) file_get_contents( $root . '/' . $file ), $file );
|
|
}
|
|
$this->assertFileDoesNotExist( $root . '/includes/class-tmdo-hpct-import.php' );
|
|
}
|
|
|
|
public function test_memo_cache_avoids_repeat_probing(): void {
|
|
WPDO_HivePress_Conflict_Guard::reset_for_tests();
|
|
$first = WPDO_HivePress_Conflict_Guard::detect_conflicts();
|
|
$second = WPDO_HivePress_Conflict_Guard::detect_conflicts();
|
|
$this->assertSame( $first, $second );
|
|
}
|
|
}
|