feat: wire rest transport services
This commit is contained in:
@@ -6,11 +6,19 @@ use PHPUnit\Framework\TestCase;
|
||||
use WPContentSync\Admin\FileImportController;
|
||||
use WPContentSync\Container;
|
||||
use WPContentSync\Plugin;
|
||||
use WPContentSync\Rest\RestPackageController;
|
||||
use WPContentSync\Transport\FileTransportInterface;
|
||||
use WPContentSync\Transport\RestTransportClient;
|
||||
use WPContentSync\Url\MetadataUrlTransformer;
|
||||
use WPContentSync\Url\UrlTransformer;
|
||||
|
||||
class PluginTest extends TestCase {
|
||||
protected function tearDown(): void {
|
||||
unset( $GLOBALS['wpcs_test_actions'] );
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_it_registers_url_transformation_services(): void {
|
||||
$container = $this->getPluginContainer( Plugin::create() );
|
||||
|
||||
@@ -36,6 +44,28 @@ class PluginTest extends TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_registers_rest_transport_services(): void {
|
||||
$container = $this->getPluginContainer( Plugin::create() );
|
||||
|
||||
self::assertInstanceOf(
|
||||
RestTransportClient::class,
|
||||
$container->get( RestTransportClient::class )
|
||||
);
|
||||
self::assertInstanceOf(
|
||||
RestPackageController::class,
|
||||
$container->get( RestPackageController::class )
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_hooks_rest_package_controller_on_register(): void {
|
||||
unset( $GLOBALS['wpcs_test_actions'] );
|
||||
|
||||
$plugin = Plugin::create();
|
||||
$plugin->register();
|
||||
|
||||
self::assertArrayHasKey( 'rest_api_init', $GLOBALS['wpcs_test_actions'] );
|
||||
}
|
||||
|
||||
private function getPluginContainer( Plugin $plugin ): Container {
|
||||
$reflection = new \ReflectionClass( $plugin );
|
||||
$property = $reflection->getProperty( 'container' );
|
||||
|
||||
Reference in New Issue
Block a user