Xpressengine\Storage\FilesystemHandler::read PHP Method

read() public method

read file contents
public read ( File $file ) : string
$file File file instance
return string
    public function read(File $file)
    {
        return $this->getDisk($file->disk)->get($file->getPathname());
    }

Usage Example

 public function testRead()
 {
     list($filesystem) = $this->getMocks();
     $instance = new FilesystemHandler($filesystem);
     $mockFile = m::mock('Xpressengine\\Storage\\File');
     $mockFile->shouldReceive('getAttribute')->once()->with('disk')->andReturn('local');
     $mockFile->shouldReceive('getPathname')->andReturn('attached/filenamestring');
     $mockFilesystem = m::mock('Illuminate\\Contracts\\Filesystem\\Filesystem');
     $mockFilesystem->shouldReceive('get')->once()->with('attached/filenamestring')->andReturn('content');
     $filesystem->shouldReceive('disk')->once()->with('local')->andReturn($mockFilesystem);
     $this->assertEquals('content', $instance->read($mockFile));
 }