/** * @covers WindowsAzure\ServiceRuntime\Internal\FileInputChannel::getInputStream * @covers WindowsAzure\ServiceRuntime\Internal\FileInputChannel::closeInputStream */ public function testGetInputStream() { $rootDirectory = 'root'; $fileName = 'test.txt'; $fileContent = 'somecontent'; // Setup vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); // Test $fileInputChannel = new FileInputChannel(); $inputStream = $fileInputChannel->getInputStream(vfsStream::url($rootDirectory . '/' . $fileName)); $inputChannelContents = stream_get_contents($inputStream); $this->assertEquals($fileContent, $inputChannelContents); $fileInputChannel->closeInputStream(); // invalid file $this->setExpectedException(get_class(new ChannelNotAvailableException())); $fileInputChannel->getInputStream(vfsStream::url($rootDirectory . '/' . 'fakeinput')); }