Files
2meet-data-optimizer/tests/unit/ModeManagerDefaultsTest.php
T
wpdev fc0f018a94 fix(2meet-data-optimizer): stop auto-activating entity bridge on install
- install() no longer switches the Hook Bus on or puts user/term/comment
  into dual_write; the now-unused maybe_autoactivate_entity_bridge() is gone
- Hook Bus and Mode_Manager defaults are off/disabled; sites with stored
  modes (incl. aeav_only) keep them since only unset keys use defaults
- Guard run_dbdelta()'s upgrade.php require like install_v2_tables() so
  install() can run under the integration test stub

Verify: InstallerV2Test::test_install_does_not_enable_entity_bridge,
  ModeManagerDefaultsTest; unit 602 OK, integration 421 OK
PR: PR-007
2026-09-25 21:48:23 +08:00

51 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
/**
* Unit test: TMDO_Mode_Manager defaults.
*
* A fresh install must not route any entity through the flat tables until an
* admin opts in; stored modes (e.g. aeav_only on live sites) must be kept as-is.
*/
class ModeManagerDefaultsTest extends TestCase {
protected function setUp(): void {
$GLOBALS['_wp_options'] = array();
TMDO_Mode_Manager::reset_cache();
}
protected function tearDown(): void {
TMDO_Mode_Manager::reset_cache();
}
public function test_all_entities_default_to_disabled(): void {
$this->assertSame(
array(
'post' => TMDO_Mode_Manager::MODE_DISABLED,
'user' => TMDO_Mode_Manager::MODE_DISABLED,
'term' => TMDO_Mode_Manager::MODE_DISABLED,
'comment' => TMDO_Mode_Manager::MODE_DISABLED,
),
TMDO_Mode_Manager::all()
);
}
public function test_stored_modes_are_kept(): void {
update_option(
'wpdo_bridge_modes',
array(
'post' => 'aeav_only',
'user' => 'dual_write',
)
);
$modes = TMDO_Mode_Manager::all();
$this->assertSame( 'aeav_only', $modes['post'] );
$this->assertSame( 'dual_write', $modes['user'] );
$this->assertSame( TMDO_Mode_Manager::MODE_DISABLED, $modes['term'] );
}
}