feat: wire file transport services
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
namespace WPContentSync\Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use WPContentSync\Admin\FileImportController;
|
||||
use WPContentSync\Container;
|
||||
use WPContentSync\Plugin;
|
||||
use WPContentSync\Transport\FileTransportInterface;
|
||||
use WPContentSync\Url\MetadataUrlTransformer;
|
||||
use WPContentSync\Url\UrlTransformer;
|
||||
|
||||
@@ -21,6 +23,19 @@ class PluginTest extends TestCase {
|
||||
self::assertSame( $metadata_transformer, $container->get( MetadataUrlTransformer::class ) );
|
||||
}
|
||||
|
||||
public function test_it_registers_file_transport_services(): void {
|
||||
$container = $this->getPluginContainer( Plugin::create() );
|
||||
|
||||
self::assertInstanceOf(
|
||||
FileTransportInterface::class,
|
||||
$container->get( FileTransportInterface::class )
|
||||
);
|
||||
self::assertInstanceOf(
|
||||
FileImportController::class,
|
||||
$container->get( FileImportController::class )
|
||||
);
|
||||
}
|
||||
|
||||
private function getPluginContainer( Plugin $plugin ): Container {
|
||||
$reflection = new \ReflectionClass( $plugin );
|
||||
$property = $reflection->getProperty( 'container' );
|
||||
|
||||
@@ -395,6 +395,32 @@ if ( ! function_exists( 'add_query_arg' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wp_nonce_field' ) ) {
|
||||
/**
|
||||
* Minimal nonce field renderer for unit tests.
|
||||
*
|
||||
* @param string $action Nonce action.
|
||||
* @param string $name Field name.
|
||||
* @return void
|
||||
*/
|
||||
function wp_nonce_field( $action, $name ) {
|
||||
echo '<input type="hidden" name="' . esc_attr( $name ) . '" value="' . esc_attr( $action ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'submit_button' ) ) {
|
||||
/**
|
||||
* Minimal submit button renderer for unit tests.
|
||||
*
|
||||
* @param string $text Button text.
|
||||
* @param string $type Button type.
|
||||
* @return void
|
||||
*/
|
||||
function submit_button( $text, $type = 'primary' ) {
|
||||
echo '<button class="button button-' . esc_attr( $type ) . '" type="submit">' . esc_html( $text ) . '</button>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wp_die' ) ) {
|
||||
/**
|
||||
* Minimal WordPress die handler for unit tests.
|
||||
|
||||
Reference in New Issue
Block a user