ecf4ff4938
- missing_integration_addons() no longer asks for the SSO AddOn when 2meet-hub-core / 2meet-spoke-sso are active: they register their own tables and the `sso` values belong in usermeta (benchmark: no measurable gain from the flat table for by-user-id access). - `sso` joins the deprecated AddOns; for hub / spoke / sso the notice says they go without replacement and to run `wp tmdo bridge-restore-native user --group=sso --retire` first. - Verify: core unit 658 / integration 479 green, phpcs clean - PR: PR-043
86 lines
3.0 KiB
PHP
86 lines
3.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* The 8 AddOns for in-house 2meet plugins are deprecated: each partner plugin
|
|
* registers its own tables and fields with the TMDO_Anti_EAV_Aware trait
|
|
* (docs/PARTNER-REGISTRATION.md). Admins running one get told so.
|
|
*/
|
|
class DeprecatedAddonsNoticeTest extends TestCase {
|
|
|
|
protected function setUp(): void {
|
|
if ( ! class_exists( 'TMDO_Deprecated_Addons_Notice' ) ) {
|
|
require_once TMDO_PATH . 'admin/class-tmdo-deprecated-addons-notice.php';
|
|
}
|
|
$GLOBALS['_wp_options'] = array();
|
|
$GLOBALS['_wp_current_user_can'] = array( 'manage_options' => true );
|
|
$GLOBALS['_wp_is_multisite'] = false;
|
|
}
|
|
|
|
private function activate( string ...$slugs ): void {
|
|
$GLOBALS['_wp_options']['active_plugins'] = array_map(
|
|
static fn( $s ) => "2meet-data-optimizer-{$s}-addon/2meet-data-optimizer-{$s}-addon.php",
|
|
$slugs
|
|
);
|
|
}
|
|
|
|
public function test_lists_only_active_deprecated_addons(): void {
|
|
$this->activate( 'spoke', 'hivepress', 'bookings' );
|
|
|
|
$this->assertSame( array( 'bookings', 'spoke' ), TMDO_Deprecated_Addons_Notice::active() );
|
|
}
|
|
|
|
public function test_notice_names_the_addons_and_points_to_the_guide(): void {
|
|
$this->activate( 'spoke' );
|
|
|
|
ob_start();
|
|
TMDO_Deprecated_Addons_Notice::render();
|
|
$html = (string) ob_get_clean();
|
|
|
|
$this->assertStringContainsString( '2meet-data-optimizer-spoke-addon', $html );
|
|
$this->assertStringContainsString( 'PARTNER-REGISTRATION.md', $html );
|
|
}
|
|
|
|
public function test_sso_hub_and_spoke_addons_are_deprecated_without_replacement(): void {
|
|
$this->activate( 'hub', 'sso' );
|
|
|
|
$this->assertSame( array( 'hub', 'sso' ), TMDO_Deprecated_Addons_Notice::active() );
|
|
ob_start();
|
|
TMDO_Deprecated_Addons_Notice::render();
|
|
$html = (string) ob_get_clean();
|
|
|
|
$this->assertStringContainsString( '2meet-data-optimizer-sso-addon', $html );
|
|
$this->assertStringContainsString( '不需替代', $html );
|
|
$this->assertStringContainsString( 'bridge-restore-native user --group=sso --retire', $html );
|
|
}
|
|
|
|
public function test_no_notice_when_none_active_or_user_cannot_manage(): void {
|
|
ob_start();
|
|
TMDO_Deprecated_Addons_Notice::render();
|
|
$this->assertSame( '', ob_get_clean() );
|
|
|
|
$this->activate( 'spoke' );
|
|
$GLOBALS['_wp_current_user_can'] = array();
|
|
ob_start();
|
|
TMDO_Deprecated_Addons_Notice::render();
|
|
$this->assertSame( '', ob_get_clean() );
|
|
}
|
|
|
|
public function test_trait_passes_post_type_scope_to_the_registry(): void {
|
|
TMDO_Entity_Registry::init();
|
|
TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) );
|
|
$partner = new class() {
|
|
use TMDO_Anti_EAV_Aware;
|
|
|
|
public function run(): bool {
|
|
return $this->register_entity_fields( 'post', 'x_item', array( array( 'key' => 'x_price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'x_item' ) ) );
|
|
}
|
|
};
|
|
|
|
$this->assertTrue( $partner->run() );
|
|
$this->assertSame( array( 'x_item' ), TMDO_Entity_Registry::get_group_post_types( 'post', 'x_item' ) );
|
|
}
|
|
}
|