feat: add connection diagnostics

This commit is contained in:
Keith Solomon
2026-05-07 06:42:40 -05:00
parent 4d83bd4a48
commit 3f643d9e41
6 changed files with 296 additions and 0 deletions
+19
View File
@@ -4,6 +4,7 @@ namespace WPContentSync\Tests\Unit;
use PHPUnit\Framework\TestCase;
use WPContentSync\Admin\FileImportController;
use WPContentSync\Admin\ConnectionTestController;
use WPContentSync\Admin\SettingsController;
use WPContentSync\Content\ContentHandlerRegistry;
use WPContentSync\Content\ContentRecordNormalizer;
@@ -61,6 +62,15 @@ class PluginTest extends TestCase {
);
}
public function test_it_registers_connection_test_controller(): void {
$container = $this->getPluginContainer( Plugin::create() );
self::assertInstanceOf(
ConnectionTestController::class,
$container->get( ConnectionTestController::class )
);
}
public function test_it_registers_rest_transport_services(): void {
$container = $this->getPluginContainer( Plugin::create() );
@@ -104,6 +114,15 @@ class PluginTest extends TestCase {
self::assertArrayHasKey( 'admin_post_wpcs_save_settings', $GLOBALS['wpcs_test_actions'] );
}
public function test_it_hooks_connection_test_controller_on_register(): void {
unset( $GLOBALS['wpcs_test_actions'] );
$plugin = Plugin::create();
$plugin->register();
self::assertArrayHasKey( 'admin_post_wpcs_test_connection', $GLOBALS['wpcs_test_actions'] );
}
private function getPluginContainer( Plugin $plugin ): Container {
$reflection = new \ReflectionClass( $plugin );
$property = $reflection->getProperty( 'container' );