/** * Registers the WP Test Stream Wrapper * * Helper function that prepares the WordPress Test Stream Wrapper for use. * * @since 1.0.0 */ function wp_test_stream_wrapper_register() { $scheme = 'test'; // Wrapper scheme // Wrapper registration metadata $wrapper_metadata = array('name' => 'WP Test Stream Wrapper', 'class' => 'WP_Test_Stream_Wrapper', 'description' => 'WP Test Stream Wrapper provides a simple extension of the WP_Local_Stream_Wrapper_Base class.'); // Register this wrapper WP_Stream_Wrapper_Registry::register_wrapper($scheme, $wrapper_metadata); }
/** * Registers the WP Local Stream Wrapper * * Information about this stream wrapper: * * Scheme : local * Class : WP_Local_Stream_Wrapper * Description: WP Local Stream Wrapper provides a simple example of * leveraging the WP_Local_Stream_Wrapper_Base class to create * simple wrappers capable of manipulating local files. * * @since 1.0.0 */ function wp_local_stream_wrapper_register() { $scheme = 'local'; // Wrapper scheme // Wrapper registration metadata $wrapper_metadata = array('name' => 'WP Local Stream Wrapper', 'class' => 'WP_Local_Stream_Wrapper', 'description' => 'WP Local Stream Wrapper provides a simple example of leveraging the WP_Local_Stream_Wrapper_Base class to create simple wrappers capable of manipulating local files.'); /** * This file contains the WP Local Stream wrapper implementation */ require_once 'wp-local-stream-wrapper-class.php'; // Register this wrapper WP_Stream_Wrapper_Registry::register_wrapper($scheme, $wrapper_metadata); }
/** * Teardown this test case */ function tearDown() { // Unregister test stream wrapper WP_Stream_Wrapper_Registry::unregister_wrapper('test'); }
/** * Teardown this test case */ function tearDown() { unlink($this->uri); $this->assertFileNotExists($this->uri); // Unregister test stream wrapper WP_Stream_Wrapper_Registry::unregister_wrapper('test'); }
/** * Returns ths class name of the wrapper implementation for given scheme * * @param string $scheme * the stream scheme. * @return string * the class name of the registered wrapper handler, or false if * there is no registered handler. * * @access public * @static * @since 1.0.0 */ public static function wrapper_class_name($scheme) { $wrappers = WP_Stream_Wrapper_Registry::get_stream_wrappers(); return empty($wrappers[$scheme]) ? false : $wrappers[$scheme]['class']; }
/** * Test cloning the registry * * Attempting to clone the registry should trigger an error. */ public function test_clone() { $this->setExpectedException('PHPUnit_Framework_Error'); $cloned_registry = clone WP_Stream_Wrapper_Registry::get_registry(); }
/** * Gets the entire stream wrapper registry * * Returns the entire stream wrapper registry, or initializes a new * registry if one does not exist. * * @return object * A singleton object for the stream wrapper registry. * * @access public * @static * @see WP_Stream_Wrapper_Registry::get_stream_wrappers() * @since 1.0.0 */ public static function get_registry() { if (!isset(self::$registry)) { self::$registry = new WP_Stream_Wrapper_Registry(); } return self::$registry; }
/** * Teardown this test case */ function tearDown() { // Remove any remaining test files wp_rmdir_recursive('test://'); // Unregister test stream wrapper WP_Stream_Wrapper_Registry::unregister_wrapper('test'); }