/**
  * Connects a piped output stream to a piped input stream and disallows the
  * connect() method of the piped output stream to be called.
  */
 public function testNonReverseConnect()
 {
     // Initializes a piped output stream
     $upstream = new PipedOutputStream();
     // Initializes an event dispatcher
     $dispatcher = new EventDispatcher();
     // Initializes the listener
     $listener = [new MarkerListener(), 'mark'];
     // Adds dispatcher and listener to the piped output stream.
     $upstream->setEventDispatcher($dispatcher)->addListener($upstream::EVENT_CONNECT_BEFORE, $listener);
     // Initializes a piped input stream.
     $input = new PipedInputStream();
     // Connects the piped input stream to the piped output stream.
     // But sets 'reverse' to false.
     $input->connect($upstream, false, false);
     // Asserts the connect() method of the output stream has not been
     // called.
     $this->assertNull($listener[0]->markers[0]);
 }
 /**
  * @dataProvider getDataForTestWriteSubstringException
  * @expectedException \OutOfBoundsException
  * @expectedExceptionMessage Invalid offset or length.
  */
 public function testWriteSubstringException($sourceBytes, $offset, $length)
 {
     $input = new PipedInputStream();
     $output = new PipedOutputStream($input);
     $output->writeSubstring($sourceBytes, $offset, $length);
 }