/** * Closes a connected piped input stream. A listener is registered at * 'close.notify.before', so when the listener is called, we know the * upstream is notified. */ public function testClose() { // Initializes a piped output stream. $upstream = new PipedOutputStream(); // Initializes a piped input stream. $input = new PipedInputStream($upstream); // Initializes an event dispatcher. $dispatcher = new EventDispatcher(); // Initializes a listener. $listener = [new MarkerListener(), 'mark']; // Adds dispatcher and listener to the piped input stream. $input->setEventDispatcher($dispatcher)->addListener($input::EVENT_CLOSE_NOTIFY_BEFORE, $listener); // Closes the piped input stream. $input->close(); // Asserts closed is true. $this->assertTrue($input->isClosed()); // Asserts notify() of the piped input stream has been called. $this->assertSame($listener[0], $listener[0]->markers[0]); }