public function testApiDrain_EmptiesBuffer() { $result = $this->buffer->drain(); $this->assertSame($this->initialString, $result); $this->assertSame('', (string) $this->buffer); $this->assertTrue($this->buffer->isEmpty()); }
/** * */ private function writeEnd() { do { try { $sent = fwrite($this->resource, $this->buffer->peek()); $this->buffer->remove($sent); } catch (Error $ex) { $sent = 0; } catch (Exception $ex) { $sent = 0; } } while (is_resource($this->resource) && $sent > 0 && !$this->buffer->isEmpty()); }