コード例 #1
0
 public function testUpdateStream()
 {
     $adapter = Mockery::mock('League\\Flysystem\\AdapterInterface');
     $adapter->shouldReceive('has')->andReturn(true);
     $adapter->shouldReceive('updateStream')->andReturn(array('path' => 'file.txt'), false);
     $filesystem = new Filesystem($adapter);
     $this->assertTrue($filesystem->updateStream('file.txt', tmpfile()));
     $filesystem->flushCache();
     $this->assertFalse($filesystem->updateStream('file.txt', tmpfile()));
 }
コード例 #2
0
ファイル: FilesystemTests.php プロジェクト: xamiro-dev/xamiro
 /**
  * @dataProvider filesystemProvider
  */
 public function testPutStream(Filesystem $filesystem, $adapter, $cache)
 {
     $filesystem->flushCache();
     $stream = tmpfile();
     fwrite($stream, 'new content');
     $this->assertFalse($filesystem->has('new_file.txt'));
     $this->assertTrue($filesystem->putStream('new_file.txt', $stream));
     fclose($stream);
     unset($stream);
     $this->assertTrue($filesystem->has('new_file.txt'));
     $this->assertEquals('new content', $filesystem->read('new_file.txt'));
     $update = tmpfile();
     fwrite($update, 'modified content');
     $this->assertTrue($filesystem->putStream('new_file.txt', $update));
     $filesystem->flushCache();
     fclose($update);
     $this->assertEquals('modified content', $filesystem->read('new_file.txt'));
 }