fix(2meet-data-optimizer): stop false alarms in doctor, term-comment-diagnose and bridge-status
- doctor: entity flat tables come from the registry (TMDO_CLI::check_entity_tables()) instead of a hard-coded user list naming the never-registered sso group, which failed doctor on every site; it also reports Promotion Guard violations and the recorded drift status per entity (report_guard_and_drift()). - term-comment-diagnose: filter status comes from each filter's is_enabled() (the garbage filter and misc bucket default to off but were shown enabled); a filter whose add-on is not active shows "not installed". - bridge-status: flat_rows counts rows holding a value (wp_core keeps an all-NULL row per post: 15306% on dev36) and eav_ids of a post-type group counts only its post types. - Tests: the WP_CLI stubs record their output in $GLOBALS['_wp_cli_output']. - Verify: DoctorTest, CliFilterStatusTest, CliBridgeStatusTest (RED before); dev36 doctor exit 1 → 0, wp_core 15306% → 100%. - PR: PR-076
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* `wp tmdo term-comment-diagnose` filter chain status (2.2 PR-076).
|
||||
*
|
||||
* It read each filter's option with a default of '1', while the garbage filter
|
||||
* and misc bucket default to off: a site that never touched them was told they
|
||||
* were enabled. The status now comes from each filter's own is_enabled().
|
||||
*/
|
||||
class CliFilterStatusTest extends TestCase {
|
||||
|
||||
protected function setUp(): void {
|
||||
$GLOBALS['_wp_options'] = array();
|
||||
$GLOBALS['_wp_cli_output'] = array();
|
||||
}
|
||||
|
||||
private function filter_line( string $class, string $label ): string {
|
||||
$method = new ReflectionMethod( TMDO_CLI_Term_Comment::class, 'print_filter_status' );
|
||||
$method->setAccessible( true );
|
||||
$method->invoke( null, $class, $label );
|
||||
return (string) end( $GLOBALS['_wp_cli_output'] );
|
||||
}
|
||||
|
||||
public function test_filters_off_by_default_show_disabled(): void {
|
||||
$this->assertStringContainsString( 'disabled', $this->filter_line( 'TMDO_Term_Comment_Garbage_Filter', 'Garbage filter' ) );
|
||||
$this->assertStringContainsString( 'disabled', $this->filter_line( 'TMDO_Term_Comment_Misc_Bucket', 'Misc bucket' ) );
|
||||
}
|
||||
|
||||
public function test_an_enabled_filter_shows_enabled(): void {
|
||||
$GLOBALS['_wp_options'][ TMDO_Term_Comment_Garbage_Filter::OPT_ENABLED ] = '1';
|
||||
|
||||
$this->assertStringContainsString( '✓ enabled', $this->filter_line( 'TMDO_Term_Comment_Garbage_Filter', 'Garbage filter' ) );
|
||||
}
|
||||
|
||||
public function test_a_filter_whose_add_on_is_not_active_says_so(): void {
|
||||
$this->assertStringContainsString( 'not installed', $this->filter_line( 'TMDO_No_Such_Filter', 'WC term count filter' ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user