feat: save admin sync settings

This commit is contained in:
Keith Solomon
2026-05-07 06:28:41 -05:00
parent 9f945955d1
commit c84df8b5f2
4 changed files with 149 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\SettingsController;
use WPContentSync\Content\ContentHandlerRegistry;
use WPContentSync\Content\ContentRecordNormalizer;
use WPContentSync\Content\MediaContentHandler;
@@ -51,6 +52,15 @@ class PluginTest extends TestCase {
);
}
public function test_it_registers_settings_controller(): void {
$container = $this->getPluginContainer( Plugin::create() );
self::assertInstanceOf(
SettingsController::class,
$container->get( SettingsController::class )
);
}
public function test_it_registers_rest_transport_services(): void {
$container = $this->getPluginContainer( Plugin::create() );
@@ -85,6 +95,15 @@ class PluginTest extends TestCase {
self::assertArrayHasKey( 'rest_api_init', $GLOBALS['wpcs_test_actions'] );
}
public function test_it_hooks_settings_controller_on_register(): void {
unset( $GLOBALS['wpcs_test_actions'] );
$plugin = Plugin::create();
$plugin->register();
self::assertArrayHasKey( 'admin_post_wpcs_save_settings', $GLOBALS['wpcs_test_actions'] );
}
private function getPluginContainer( Plugin $plugin ): Container {
$reflection = new \ReflectionClass( $plugin );
$property = $reflection->getProperty( 'container' );