/**
  * Setup this test case
  */
 function setUp()
 {
     // Register test stream wrapper
     wp_test_stream_wrapper_register();
     /**
      * Initialize instance variables
      */
     $wrapper = WP_Stream::new_wrapper_instance('test://');
     $this->test_dir = $wrapper->get_wrapper_path();
     $this->filename = 'testfile.txt';
     $this->uri = 'test://' . $this->filename;
     $this->path = $this->test_dir . '/' . $this->filename;
     $this->expected_contents = 'The miracle is this - the more we share, the more we have. -- Leonard Nimoy';
     /**
      * Setup and assert starting evironment
      */
     if (file_exists($this->uri)) {
         unlink($this->uri);
     }
     $this->assertFileNotExists($this->uri);
     $this->assertFileNotExists($this->path);
     // Open and write to the file
     $fh = fopen($this->uri, 'w');
     fwrite($fh, $this->expected_contents);
     fclose($fh);
     $this->assertFileExists($this->path);
     $this->assertEquals(filesize($this->uri), filesize($this->path));
 }
 /**
  * Setup this test case
  */
 function setUp()
 {
     do_action('init');
     // Register test stream wrapper
     wp_test_stream_wrapper_register();
     // Set the expected test directory
     $wrapper = WP_Stream::new_wrapper_instance('test://');
     $this->test_dir = $wrapper->get_wrapper_path();
     $this->sample_content = 'The miracle is this - the more we share, the more we have. -- Leonard Nimoy';
     /**
      * Prepare sample file with sample contents
      */
     $this->sample_file = 'test://sample_file.txt';
     $fp = fopen($this->sample_file, 'w');
     fwrite($fp, $this->sample_content);
     fclose($fp);
     $this->assertFileExists($this->sample_file);
 }
 /**
  * Setup this test case
  */
 function setUp()
 {
     // Register test stream wrapper
     wp_test_stream_wrapper_register();
 }
 /**
  * Test getting the stream wrappers array
  *
  * Tests WP_Stream_Wrapper_Registry::get_stream_wrappers().
  */
 public function test_get_stream_wrappers()
 {
     // Register the test stream wrapper and check the schema.
     wp_test_stream_wrapper_register();
     $stream_wrappers = WP_Stream_Wrapper_Registry::get_stream_wrappers();
     // Assert that the test wrapper is registered
     $this->assertArrayHasKey('test', $stream_wrappers, 'The test stream wrapper should be registered here.');
     // Assert that the test wrapper has the proper schema
     $this->assertEquals('WP Test Stream Wrapper', $stream_wrappers['test']['name']);
     $this->assertEquals('WP_Test_Stream_Wrapper', $stream_wrappers['test']['class']);
     $this->assertEquals('WP Test Stream Wrapper provides a simple extension of the WP_Local_Stream_Wrapper_Base class.', $stream_wrappers['test']['description']);
     // Unregister test stream wrappers
     WP_Stream_Wrapper_Registry::unregister_wrapper('test');
 }