Files
2meet-data-optimizer/tests/unit/BackCompatTest.php
T
wpdev d36bb954d1 chore: initial snapshot of 2meet-data-optimizer v0.1.0
Baseline before backporting wp-data-optimizer v3.0.1-v3.4.6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:06:36 +08:00

56 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
/**
* Unit tests for TMDO back-compat layer.
*
* Verifies that WPDO_* aliases for classes, traits, and interfaces all resolve
* correctly so sister plugins compiled against old names continue to work.
*/
class BackCompatTest extends TestCase {
// ── Trait alias ──────────────────────────────────────────────────────────
public function test_wpdo_anti_eav_aware_trait_exists(): void {
$this->assertTrue( trait_exists( 'WPDO_Anti_EAV_Aware' ), 'WPDO_Anti_EAV_Aware trait alias must exist' );
}
public function test_class_using_wpdo_anti_eav_aware_is_valid(): void {
// Verify a class can `use WPDO_Anti_EAV_Aware` without fatal error.
$obj = new class {
use WPDO_Anti_EAV_Aware;
};
// trait_exists check via class_uses — PHP doesn't support instanceof for traits.
$this->assertArrayHasKey( 'WPDO_Anti_EAV_Aware', class_uses( $obj ) );
}
// ── Interface alias ───────────────────────────────────────────────────────
public function test_wpdo_entity_adapter_interface_exists(): void {
$this->assertTrue(
interface_exists( 'WPDO_Entity_Adapter_Interface' ),
'WPDO_Entity_Adapter_Interface must exist as a back-compat alias'
);
}
public function test_tmdo_adapter_post_implements_wpdo_interface(): void {
// An object implementing TMDO_Entity_Adapter_Interface must also
// satisfy `instanceof WPDO_Entity_Adapter_Interface`.
$adapter = new TMDO_Adapter_Post();
$this->assertInstanceOf( 'WPDO_Entity_Adapter_Interface', $adapter );
}
// ── DB version consistency ────────────────────────────────────────────────
public function test_tmdo_db_version_constant_matches_installer_schema(): void {
// TMDO_DB_VERSION (plugin header constant) must equal TMDO_Installer::SCHEMA_VERSION
// (private). If they diverge, maybe_upgrade() either never fires or fires every boot.
$ref = new ReflectionClass( TMDO_Installer::class );
$schema_version = $ref->getConstant( 'SCHEMA_VERSION' );
$this->assertSame( TMDO_DB_VERSION, $schema_version,
'TMDO_DB_VERSION constant must match TMDO_Installer::SCHEMA_VERSION' );
}
}