Beispiel #1
0
 /**
  * Write a new file using a stream.
  *
  * @param string $path
  * @param resource $resource
  * @param Config $config
  * @return array|false
  */
 public function writeStream($path, $resource, Config $config)
 {
     $fullPath = $this->applyPathPrefix($path);
     $stream = $this->share->write($fullPath);
     stream_copy_to_stream($resource, $stream);
     return fclose($stream) ? compact('path') : false;
 }
 /**
  * @dataProvider nameAndDataProvider
  */
 public function testWriteStream($name, $text)
 {
     $fh = $this->share->write($this->root . '/' . $name);
     fwrite($fh, $text);
     fclose($fh);
     $tmpFile1 = tempnam('/tmp', 'smb_test_');
     $this->share->get($this->root . '/' . $name, $tmpFile1);
     $this->assertEquals($text, file_get_contents($tmpFile1));
     $this->share->del($this->root . '/' . $name);
     unlink($tmpFile1);
 }
 /**
  * @dataProvider invalidPathProvider
  * @expectedException \Icewind\SMB\Exception\InvalidPathException
  */
 public function testWriteStreamInvalidPath($name)
 {
     $fh = $this->share->write($this->root . '/' . $name);
     fwrite($fh, 'foo');
     fclose($fh);
 }