/** * Checks the validity of a given stream wrapper scheme * * Confirms that there is a registered stream handler for the given * scheme and that it is callable. This is useful if you want to confirm * a valid scheme without creating a new instance of the registered * wrapper. * * @param string $scheme * the stream scheme. * @return bool * true if the scheme is valid, or false if the scheme does not have * a registered handler. * * @access public * @static * @since 1.0.0 */ public static function scheme_valid($scheme) { $class_name = WP_Stream::wrapper_class_name($scheme); if (class_exists($class_name)) { return true; } else { return false; } }
/** * Tests getting the wrapper class name * * Tests WP_Stream::wrapper_class_name() */ public function test_wrapper_class_name() { $scheme = 'test'; $expected = 'WP_Test_Stream_Wrapper'; $actual = WP_Stream::wrapper_class_name($scheme); $this->assertEquals($expected, $actual, "WP_Stream::wrapper_class_name returned '{$actual}' instead of the expected '{$expected}'"); }
/** * Tests setting and getting URI * * Tests the $uri attribute of */ public function test_uri_attribute() { $uri = 'test://testfile.txt'; $scheme = WP_Stream::scheme($uri); $class_name = WP_Stream::wrapper_class_name($scheme); $instance = WP_Stream::new_wrapper_instance($uri); $this->assertEquals($uri, $instance->get_uri()); $new_uri = 'test://testfile2.txt'; $instance->set_uri($new_uri); $this->assertEquals($new_uri, $instance->get_uri()); }