/** * @param \Gaufrette\Stream $stream */ function it_should_not_unlink_when_cannot_open($stream) { $stream->open(ANY_ARGUMENT)->willThrow(new \RuntimeException()); $this->unlink('gaufrette://some/filename')->shouldReturn(false); }
protected function openStream(Stream $stream, $mode) { // always use binary mode $mode = $mode . 'b+'; return $stream->open(new StreamMode($mode)); }
/** * Copy stream to storage * * @param Stream $srcStream * @param string $destinationFileName */ protected function copyStreamToStorage(Stream $srcStream, $destinationFileName) { $dstStream = $this->filesystem->createStream($destinationFileName); $srcStream->open(new StreamMode('rb+')); $dstStream->open(new StreamMode('wb+')); while (!$srcStream->eof()) { $dstStream->write($srcStream->read(self::READ_COUNT)); } $dstStream->close(); $srcStream->close(); }
/** * @param \Gaufrette\Stream $stream */ function it_casts_stream($stream) { $stream->open(Argument::any())->willReturn(true); $stream->cast(STREAM_CAST_FOR_SELECT)->willReturn('resource'); $this->stream_open('gaufrette://some/filename', 'w+'); $this->stream_cast(STREAM_CAST_FOR_SELECT)->shouldReturn('resource'); }