public function set_up() { $this->helper('directory'); vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir')); $this->_test_dir = vfsStreamWrapper::getRoot(); }
/** * test that the directory is created */ public function testDirectoryIsCreated() { $example = new Example('id'); $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('id')); $example->setDirectory(vfsStream::url('exampleDir')); $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('id')); }
/** * @covers Generator::generate_test */ function testGenerateTest() { mkdir(vfsStream::url('root/test/unit'), 0777, true); file_put_contents(vfsStream::url('root/template/unit_test.tmpl'), '{class_name}'); Generator::generate_test('unit', 'Unit'); $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('test/unit/UnitTest.php')); $this->assertEquals("Unit", file_get_contents(vfsStream::url('test/unit/UnitTest.php'))); }
function setUp() { TestRequire::vfs($this); vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('r')); $this->fsroot = vfsStreamWrapper::getRoot(); $this->ua = new UnitAnalyzer(); }
function testScriptExistsAndFails() { vfsStream::newFile('script')->at(vfsStreamWrapper::getRoot()); $script_runner = new TryLib_Precheck_ScriptRunner(vfsStream::url('testDir/script')); $this->mock_cmd_runner->expects($this->once())->method('run')->with('vfs://testDir/script', false, true)->will($this->returnValue(255)); $this->mock_cmd_runner->expects($this->once())->method('terminate')->with('Failed running pre-check script vfs://testDir/script'); $script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/master'); }
protected function setUp() { TestRequire::vfs($this); $this->fa = new FrequencyAnalyzer(); vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('r')); $this->fs = vfsStreamWrapper::getRoot(); }
/** * Setup */ protected function setUp() { if ($this->isVsfStreamInstalled()) { vfsStream::setup(); $this->setTestDirectory(vfsStream::newDirectory('tests')->at(vfsStreamWrapper::getRoot())); define('CLIENT_DATA_DIR', vfsStream::url('root/tests')); } parent::setUp(); }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); vfsStream::setup('exampleDir'); $file = vfsStream::newFile('test1.php'); vfsStreamWrapper::getRoot()->addChild($file); $file->setContent('__' . '("test1"); __' . '(\'test2\')'); $this->Translation_File_Source = new Translation_File_Source(vfsStream::url('exampleDir/test1.php')); }
/** * @dataProvider extractSource_dp */ public function testExtractSource($units, $file_content, $expected) { $f = vfsStream::newFile('file.php', 0664); $f->withContent($file_content); vfsStreamWrapper::getRoot()->addChild($f); $this->sa->extractSource($units[0]); $this->assertEquals(explode("\n", $expected['src']), explode("\n", $units[0]['src'])); $this->assertEquals(explode("\n", $expected['src_strip']), explode("\n", $units[0]['src_strip'])); $this->assertEquals(explode("\n", $expected['sloc']), explode("\n", $units[0]['sloc'])); $this->assertEquals(explode("\n", $expected['err']), explode("\n", $units[0]['err'])); }
function set_up() { $obj = new stdClass(); $obj->upload = new Mock_Libraries_Upload(); $obj->security = new Mock_Core_Security(); $obj->lang = new Mock_Core_Lang(); $this->ci_instance($obj); $this->upload = $obj->upload; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir')); $this->_test_dir = vfsStreamWrapper::getRoot(); }
protected function setUp() { global $xml_file_data; TestRequire::vfs($this); vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('r')); $this->fs = vfsStreamWrapper::getRoot(); $f = new vfsStreamFile('file.xml', 0664); $f->withContent($xml_file_data); $this->fs->addChild($f); $this->xa = new XMLAnalyzer(vfsStream::url('file.xml')); }
public static function newFile($contents, $fileName = null, $root = null) { $root = is_null($root) ? 'root' : $root; $fileName = is_null($fileName) ? 'test.txt' : $fileName; \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($root)); $file = \vfsStream::newFile($fileName); $file->setContent($contents); \vfsStreamWrapper::getRoot()->addChild($file); $virtualPath = \vfsStream::url($root . '/' . $fileName); return $virtualPath; }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); vfsStream::setup('exampleDir'); $dir = vfsStream::newDirectory('subDir1'); vfsStreamWrapper::getRoot()->addChild($dir); vfsStreamWrapper::getRoot()->addChild(vfsStream::newFile('test1.php')); $dir->addChild(vfsStream::newFile('test2.php')); $dir->addChild(vfsStream::newFile('test3.js')); $dir->addChild(vfsStream::newFile('test4.xml')); $extentions = array('php' => array('PHP')); $this->Translation_Collector_Source_Files = new Translation_Collector_Source_Files(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(vfsStream::url('exampleDir'))), $extentions); }
/** * @test * @author Robert Lemke <*****@*****.**> */ public function initializeObjectRemovesALockFileIfItsOlderThanTheMaximumTime() { $temporaryDirectoryUrl = \vfsStream::url('TestDirectory') . '/'; file_put_contents($temporaryDirectoryUrl . 'FLOW3.lock', ''); \vfsStreamWrapper::getRoot()->getChild('FLOW3.lock')->setFilemtime(time() - \F3\FLOW3\Core\LockManager::LOCKFILE_MAXIMUM_AGE - 2); $mockEnvironment = $this->getMock('F3\\FLOW3\\Utility\\Environment'); $mockEnvironment->expects($this->once())->method('getPathToTemporaryDirectory')->will($this->returnValue($temporaryDirectoryUrl)); $lockManager = new \F3\FLOW3\Core\LockManager(); $lockManager->injectEnvironment($mockEnvironment); $lockManager->initializeObject(); $this->assertFalse($lockManager->isSiteLocked()); $this->assertFalse(file_exists($temporaryDirectoryUrl . 'FLOW3.lock')); }
/** * Since we use paths to load up models, views, etc, we need the ability to * mock up the file system so when core tests are run, we aren't mucking * in the application directory. this will give finer grained control over * these tests. So yeah, while this looks odd, I need to overwrite protected * class vars in the loader. So here we go... * * @covers CI_Loader::__construct() */ public function __construct() { vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('application')); $this->models_dir = vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot()); $this->libs_dir = vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot()); $this->helpers_dir = vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot()); $this->views_dir = vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot()); $this->_ci_ob_level = ob_get_level(); $this->_ci_library_paths = array(vfsStream::url('application') . '/', BASEPATH); $this->_ci_helper_paths = array(vfsStream::url('application') . '/', BASEPATH); $this->_ci_model_paths = array(vfsStream::url('application') . '/'); $this->_ci_view_paths = array(vfsStream::url('application') . '/views/' => TRUE); }
public function __construct() { if (class_exists('vfsStream')) { vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('pluginDir')); $this->pluginDir = vfsStream::url('testDir'); file_put_contents(sprintf('%s/Fake2Plugin.php', $this->pluginDir), '<?php /* sample */ ?>'); file_put_contents(sprintf('%s/Fake1Plugin.php', $this->pluginDir), '<?php /* sample */ ?>'); $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild(sprintf('%s/Fake2Plugin.php', $this->pluginDir)), 'Init validation that vfs file does not exist failed'); } $this->vfsPath = $this->pluginDir; $config = array('paths' => array('plugins' => $this->pluginDir, 'userdata' => $this->pluginDir), 'plugins' => array('activePlugins' => 'Fake2,Fake1')); $params = array('config' => arrayToObject($config)); $this->plugin = new Plugin($params); }
/** * Tests Translation_File_Output->save() */ public function testSave() { $container = new Translation_WordsContainer(); $container->addWord(new Translation_Word('test1')); $container->addWord(new Translation_Word('test2"')); $container->addWord(new Translation_Word('test3\'')); $this->Translation_File_Output->setTranslatableWordsContainer($container); $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('subdir1')); $this->Translation_File_Output->save(); $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('subdir1')); $this->assertTrue(vfsStreamWrapper::getRoot()->getChild('subdir1')->hasChild('subdir2')); $this->assertTrue(vfsStreamWrapper::getRoot()->getChild('subdir1')->getChild('subdir2')->hasChild('test.js')); $file = vfsStreamWrapper::getRoot()->getChild('subdir1')->getChild('subdir2')->getChild('test.js'); $this->assertNotEquals('', $file->getContent()); }
public function testOpen() { $dir = vfsStream::setup('base'); $sut = new Dfp_Datafeed_File_Writer_Format_Csv_File(); $sut->open(vfsStream::url('base/test.csv')); $this->assertTrue($sut->isOpen()); $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('test.csv')); vfsStreamWrapper::getRoot()->chmod(0400); try { $sut->open(vfsStream::url('base/testnowrite.csv')); } catch (Dfp_Datafeed_File_Writer_Exception $e) { if ($e->getMessage() == 'Unable to open feed') { return; } } $this->fail('Exception not thrown'); }
/** * @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')); }
/** * @covers WindowsAzure\ServiceRuntime\Internal\Protocol1RuntimeCurrentStateClient::setEndpoint * @covers WindowsAzure\ServiceRuntime\Internal\Protocol1RuntimeCurrentStateClient::setCurrentState */ public function testSetCurrentState() { // Setup $rootDirectory = 'root'; $fileName = 'test'; $fileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<CurrentState>' . '<StatusLease ClientId="clientId">' . '<Acquire>' . '<Incarnation>1</Incarnation>' . '<Status>Recycle</Status>' . '<Expiration>2000-01-01T00:00:00.0000000Z</Expiration>' . '</Acquire>' . '</StatusLease>' . '</CurrentState>'; \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory)); $file = \vfsStream::newFile($fileName); \vfsStreamWrapper::getRoot()->addChild($file); $serializer = new XmlCurrentStateSerializer(); $fileOutputChannel = new FileOutputChannel(); $protocol1RuntimeCurrentStateClient = new Protocol1RuntimeCurrentStateClient($serializer, $fileOutputChannel); $protocol1RuntimeCurrentStateClient->setEndpoint(\vfsStream::url($rootDirectory . '/' . $fileName)); // Test $recycleState = new AcquireCurrentState('clientId', 1, CurrentStatus::RECYCLE, new \DateTime('2000-01-01', new \DateTimeZone('UTC'))); $protocol1RuntimeCurrentStateClient->setCurrentState($recycleState); $fileInputChannel = new FileInputChannel(); $fileInputStream = $fileInputChannel->getInputStream(\vfsStream::url($rootDirectory . '/' . $fileName)); $inputChannelContents = stream_get_contents($fileInputStream); $this->assertEquals($fileContents, $inputChannelContents); }
/** * @covers WindowsAzure\ServiceRuntime\Internal\FileOutputChannel::getOutputStream */ public function testGetOutputStream() { $rootDirectory = 'root'; $fileName = 'test.txt'; $fileContents = 'Hello World!'; // Setup \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory)); $file = \vfsStream::newFile($fileName); \vfsStreamWrapper::getRoot()->addChild($file); // Test $fileOutputChannel = new FileOutputChannel(); $outputStream = $fileOutputChannel->getOutputStream(\vfsStream::url($rootDirectory . '/' . $fileName)); // Write content to file fwrite($outputStream, $fileContents); fclose($outputStream); // Test file content $fileInputChannel = new FileInputChannel(); $fileInputStream = $fileInputChannel->getInputStream(\vfsStream::url($rootDirectory . '/' . $fileName)); $inputChannelContents = stream_get_contents($fileInputStream); $this->assertEquals($fileContents, $inputChannelContents); }
/** * @covers WindowsAzure\ServiceRuntime\Internal\XmlCurrentStateSerializer::serialize */ public function testSerializeRelease() { // Setup $rootDirectory = 'root'; $fileName = 'test'; $fileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<CurrentState>' . '<StatusLease ClientId="clientId">' . '<Release/>' . '</StatusLease>' . '</CurrentState>'; // Setup \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory)); $file = \vfsStream::newFile($fileName); \vfsStreamWrapper::getRoot()->addChild($file); // Test $fileOutputChannel = new FileOutputChannel(); $outputStream = $fileOutputChannel->getOutputStream(\vfsStream::url($rootDirectory . '/' . $fileName)); $recycleState = new ReleaseCurrentState('clientId'); $xmlCurrentStateSerializer = new XmlCurrentStateSerializer(); $xmlCurrentStateSerializer->serialize($recycleState, $outputStream); fclose($outputStream); $fileInputChannel = new FileInputChannel(); $fileInputStream = $fileInputChannel->getInputStream(\vfsStream::url($rootDirectory . '/' . $fileName)); $inputChannelContents = stream_get_contents($fileInputStream); $this->assertEquals($fileContents, $inputChannelContents); }
/** * @covers WindowsAzure\ServiceRuntime\Internal\RuntimeVersionProtocolClient::getVersionMap */ public function testGetVersionMap() { // Setup $rootDirectory = 'root'; \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory)); $fileName = 'versionendpoint'; $fileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<RuntimeServerDiscovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<RuntimeServerEndpoints>' . '<RuntimeServerEndpoint version="2011-03-08" path="myPath1" />' . '<RuntimeServerEndpoint version="2012-03-08" path="myPath2" />' . '</RuntimeServerEndpoints>' . '</RuntimeServerDiscovery>'; $file = \vfsStream::newFile($fileName); $file->setContent($fileContent); \vfsStreamWrapper::getRoot()->addChild($file); $runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(new FileInputChannel()); // Test $versions = $runtimeVersionProtocolClient->getVersionMap(\vfsStream::url($rootDirectory . '/' . $fileName)); $this->assertEquals('myPath1', $versions['2011-03-08']); $this->assertEquals('myPath2', $versions['2012-03-08']); // change to a single endpoint $fileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<RuntimeServerDiscovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<RuntimeServerEndpoints>' . '<RuntimeServerEndpoint version="2011-03-08" path="myPath1" />' . '</RuntimeServerEndpoints>' . '</RuntimeServerDiscovery>'; $file->setContent($fileContent); $versions = $runtimeVersionProtocolClient->getVersionMap(\vfsStream::url($rootDirectory . '/' . $fileName)); $this->assertEquals('myPath1', $versions['2011-03-08']); $this->assertArrayNotHasKey('2012-03-08', $versions); }
/** * ensure that a call to vfsStreamWrapper::register() resets the stream * * Implemented after a request by David Zülke. * * @test */ public function resetByRegister() { $this->assertSame($this->foo, vfsStreamWrapper::getRoot()); vfsStreamWrapper::register(); $this->assertNull(vfsStreamWrapper::getRoot()); }
/** * @test * @author Karsten Dambekalns <*****@*****.**> */ public function logFileIsRotatedIfMaximumSizeIsExceeded() { $this->markTestSkipped('vfsStream does not support touch() and rename()...'); $logFileUrl = \vfsStream::url('testDirectory') . '/test.log'; file_put_contents($logFileUrl, 'twentybytesofcontent'); $backend = $this->getMock($this->buildAccessibleProxy('F3\\FLOW3\\Log\\Backend\\FileBackend'), array('dummy'), array(array('logFileUrl' => $logFileUrl))); $backend->_set('maximumLogFileSize', 10); $backend->setLogFilesToKeep(1); $backend->open(); $this->assertFalse(\vfsStreamWrapper::getRoot()->hasChild('test.log')); $this->assertTrue(\vfsStreamWrapper::getRoot()->hasChild('test.log.1')); }
/** * @covers WindowsAzure\ServiceRuntime\RoleEnvironment::trackChanges * @covers WindowsAzure\ServiceRuntime\RoleEnvironment::_raiseStoppingEvent */ public function testTrackChanges() { // Setup $rootDirectory = 'root'; \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory)); $roleEnvironmentFileName = 'roleEnvironment'; $roleEnvironmentFileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<RoleEnvironment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<Deployment id="state1" emulated="false" />' . '<CurrentInstance id="id3" roleName="roleName" faultDomain="4" updateDomain="5">' . '<LocalResources>' . '<LocalResource name="DiagnosticStore" path="somepath.DiagnosticStore" sizeInMB="4096" />' . '</LocalResources>' . '</CurrentInstance>' . '<Roles />' . '</RoleEnvironment>'; $roleEnvironmentFile = \vfsStream::newFile($roleEnvironmentFileName); $roleEnvironmentFile->setContent($roleEnvironmentFileContent); \vfsStreamWrapper::getRoot()->addChild($roleEnvironmentFile); $currentGoalStateFileName = 'currentGoalStateFile'; $currentGoalStateFile = \vfsStream::newFile($currentGoalStateFileName); \vfsStreamWrapper::getRoot()->addChild($currentGoalStateFile); $goalStateFileName = 'goalstate'; $goalStateFileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<GoalState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<Incarnation>1</Incarnation>' . '<ExpectedState>Started</ExpectedState>' . '<RoleEnvironmentPath>' . \vfsStream::url($rootDirectory . '/' . $roleEnvironmentFileName) . '</RoleEnvironmentPath>' . '<CurrentStateEndpoint>' . \vfsStream::url($rootDirectory . '/' . $currentGoalStateFileName) . '</CurrentStateEndpoint>' . '<Deadline>9999-12-31T23:59:59.9999999</Deadline>' . '</GoalState>'; $goalStateFileContent = dechex(strlen($goalStateFileContent)) . "\n" . $goalStateFileContent; $goalStateFile = \vfsStream::newFile($goalStateFileName); $goalStateFile->setContent($goalStateFileContent); \vfsStreamWrapper::getRoot()->addChild($goalStateFile); $fileName = 'versionendpoint'; $fileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<RuntimeServerDiscovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<RuntimeServerEndpoints>' . '<RuntimeServerEndpoint version="2011-03-08" path="' . \vfsStream::url($rootDirectory . '/' . $goalStateFileName) . '" />' . '</RuntimeServerEndpoints>' . '</RuntimeServerDiscovery>'; $file = \vfsStream::newFile($fileName); $file->setContent($fileContent); \vfsStreamWrapper::getRoot()->addChild($file); putenv('WaRuntimeEndpoint=' . \vfsStream::url($rootDirectory . '/' . $fileName)); // Test $this->assertEquals('state1', RoleEnvironment::getDeploymentId()); $currentGoalState = self::getStaticPropertyValue('_currentGoalState'); // Process goal state to the previous state $args = array(); $args[] = $currentGoalState; self::setStaticPropertyValue('_tracking', 1); RoleEnvironment::trackChanges(); $goalStateFileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<GoalState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<Incarnation>1</Incarnation>' . '<ExpectedState>Stopped</ExpectedState>' . '<RoleEnvironmentPath>' . \vfsStream::url($rootDirectory . '/' . $roleEnvironmentFileName) . '</RoleEnvironmentPath>' . '<CurrentStateEndpoint>' . \vfsStream::url($rootDirectory . '/' . $currentGoalStateFileName) . '</CurrentStateEndpoint>' . '<Deadline>9999-12-31T23:59:59.9999999</Deadline>' . '</GoalState>'; $goalStateFileContent = dechex(strlen($goalStateFileContent)) . "\n" . $goalStateFileContent; $goalStateFile->setContent($goalStateFileContent); RoleEnvironment::addRoleEnvironmentStoppingListener(array('Tests\\Unit\\WindowsAzure\\ServiceRuntime\\myclass', 'execute')); self::setStaticPropertyValue('_tracking', 1); RoleEnvironment::trackChanges(); $this->assertEquals(true, myclass::$_executed); }
/** * @covers WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoles * @covers WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoleInstances */ public function testTranslateRoles_OneRoles() { // Setup $rootDirectory = 'root'; \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory)); // Test multiple settings $fileName = 'roleenvironmentendpoint'; $fileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<RoleEnvironment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<Deployment id="92f5cd71a4c048ed94e1b130bd0c4639" emulated="false" />' . '<CurrentInstance id="role1" roleName="role1" faultDomain="0" updateDomain="0">' . '</CurrentInstance>' . '<Roles>' . '<Role name="role1">' . '<Instances>' . '<Instance id="deployment16(191).test.role1_IN_0" faultDomain="0" updateDomain="0">' . '<Endpoints>' . '<Endpoint name="MyInternalEndpoint1" address="127.255.0.0" port="20000" protocol="tcp" />' . '</Endpoints>' . '</Instance>' . '</Instances>' . '</Role>' . '</Roles>' . '</RoleEnvironment>'; $file = \vfsStream::newFile($fileName); $file->setContent($fileContent); \vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream(\vfsStream::url($rootDirectory . '/' . $fileName)); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize($inputStream); $this->assertNotEquals(null, $roleEnvironmentData); }
/** * @test * @group setup * @since 0.7.0 */ public function setupRegistersStreamWrapperAndCreatesRootDirectoryWithGivenNameAndPermissions() { $root = vfsStream::setup('foo', 0444); $this->assertSame($root, vfsStreamWrapper::getRoot()); $this->assertEquals('foo', $root->getName()); $this->assertEquals(0444, $root->getPermissions()); }
/** * @covers WindowsAzure\ServiceRuntime\Internal\ChunkedGoalStateDeserializer::__construct * @covers WindowsAzure\ServiceRuntime\Internal\ChunkedGoalStateDeserializer::initialize * @covers WindowsAzure\ServiceRuntime\Internal\ChunkedGoalStateDeserializer::deserialize */ public function testDeserializeWithNewLineStart() { // Setup $rootDirectory = 'root'; \vfsStreamWrapper::register(); \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory)); $roleEnvironmentPath = 'mypath'; $currentStateEndpoint = 'endpoint'; $incarnation = 1; $expectedState = 'started'; $fileName = 'file'; $fileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<GoalState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<Incarnation>' . $incarnation . '</Incarnation>' . '<ExpectedState>' . $expectedState . '</ExpectedState>' . '<RoleEnvironmentPath>' . $roleEnvironmentPath . '</RoleEnvironmentPath>' . '<CurrentStateEndpoint>' . $currentStateEndpoint . '</CurrentStateEndpoint>' . '<Deadline>9999-12-31T23:59:59.9999999</Deadline>' . '</GoalState>'; $fileContent = "\n" . dechex(strlen($fileContent)) . "\n" . $fileContent; $file = \vfsStream::newFile($fileName); $file->setContent($fileContent); \vfsStreamWrapper::getRoot()->addChild($file); $fileInputChannel = new FileInputChannel(); $fileInputStream = $fileInputChannel->getInputStream(\vfsStream::url($rootDirectory . '/' . $fileName)); $chunkedGoalStateDeserializer = new ChunkedGoalStateDeserializer(); $chunkedGoalStateDeserializer->initialize($fileInputStream); $goalState = $chunkedGoalStateDeserializer->deserialize(); // Test $this->assertNotEquals(null, $goalState); $this->assertEquals($roleEnvironmentPath, $goalState->getEnvironmentPath()); $this->assertNotEquals(null, $goalState->getDeadline()); $this->assertEquals($currentStateEndpoint, $goalState->getCurrentStateEndpoint()); $this->assertEquals($incarnation, $goalState->getIncarnation()); $this->assertEquals($expectedState, $goalState->getExpectedState()); }
/** * @test */ public function createsNoHtaccessForExistingDirectory() { $this->setUpVfsStream(); $directory = uniqid('Log'); // create a directory \vfsStreamWrapper::getRoot()->addChild(new \vfsStreamDirectory($directory)); $logFile = 'vfs://LogRoot/' . $directory . '/' . $this->logFileName; $this->assertTrue(is_dir('vfs://LogRoot/' . $directory)); $this->createWriter()->setLogFile($logFile); $this->assertFileNotExists('vfs://LogRoot/' . $directory . '/.htaccess'); }