public function testUsesCustomStreams() { $listener = new EventListener(); $es = fopen('php://memory', 'w+'); $is = fopen('php://memory', 'w+'); $os = fopen('php://memory', 'w+'); $listener->setErrorStream($es)->setOutputStream($os)->setInputStream($is); // Ensure that the output is sent to the output stream $listener->sendBusy(); $listener->sendAcknowledged(); $listener->sendComplete(); $listener->sendFail(); $listener->sendReady(); rewind($os); $this->assertEquals("BUSY\nACKNOWLEDGED\nRESULT 2\nOKRESULT 4\nFAILREADY\n", stream_get_contents($os)); // Ensure that log messages are sent to the error stream $listener->log('Test'); rewind($es); $this->assertContains('Test', fgets($es)); // Ensure that input is read from the input stream fwrite($is, 'test'); rewind($is); $this->assertEquals('test', $listener->readLine()); fclose($es); fclose($os); fclose($is); }