install_wpdb_mock(); $reflect = new ReflectionClass( WPDO_Schema_Registry::class ); $prop = $reflect->getProperty( 'instance' ); $prop->setAccessible( true ); $prop->setValue( null, null ); WPDO_Custom_Table_Registry::reset_for_tests(); $this->adapter = new WPDO_HivePress_Requests_Adapter(); } public function test_implements_adapter_interface(): void { $this->assertInstanceOf( WPDO_HivePress_Adapter::class, $this->adapter ); } public function test_identity(): void { $this->assertSame( 'hivepress-requests', $this->adapter->plugin_slug() ); $this->assertSame( 'HivePress\\Requests\\Plugin', $this->adapter->detection_class() ); $this->assertSame( 'hp_offer', WPDO_HivePress_Requests_Adapter::OFFER_COMMENT_TYPE ); } public function test_on_register_fields_registers_request_hot_columns(): void { $registry = WPDO_Schema_Registry::instance(); $this->adapter->on_register_fields( $registry ); $drafted = $registry->get_field( 'hp_request', 'hp_drafted' ); $this->assertSame( 'hot', $drafted['zone'] ); $this->assertTrue( (bool) $drafted['indexed'] ); $expired = $registry->get_field( 'hp_request', 'hp_expired_time' ); $this->assertSame( 'hot', $expired['zone'] ); $this->assertTrue( (bool) $expired['indexed'] ); } public function test_registers_no_offer_shadow_table(): void { // The offer shadow table was never created, so every mirror write failed. $registry = WPDO_Custom_Table_Registry::instance(); $this->adapter->on_register_custom_tables( $registry ); $this->assertSame( array(), $registry->all() ); } public function test_binds_no_comment_hooks(): void { $GLOBALS['_wp_filter_callbacks'] = array(); $this->adapter->on_register_event_hooks(); $this->assertArrayNotHasKey( 'wp_insert_comment', $GLOBALS['_wp_filter_callbacks'] ); $this->assertArrayNotHasKey( 'edit_comment', $GLOBALS['_wp_filter_callbacks'] ); $this->assertArrayNotHasKey( 'deleted_comment', $GLOBALS['_wp_filter_callbacks'] ); } public function test_score_aggregates_to_perfect_ten(): void { $this->assertSame( 10.0, $this->adapter->suitability_score()['aggregate'] ); } public function test_migrations_lists_only_request_hot_module(): void { $this->assertSame( array( 'hot_hp_request' ), $this->adapter->migrations() ); } }