public function testGetSchemeWithoutColonSlashSlash() { $factory = Mockery::mock('Vfs\\Node\\Factory\\NodeFactoryInterface'); $factory->shouldReceive('buildDirectory')->once()->withNoArgs()->andReturn($this->root); $fs = new FileSystem("foo://", $this->wrapperClass, $factory, $this->walker, $this->registry, $this->logger); $this->assertSame($this->scheme, $fs->getScheme()); }
/** * @return FileSystemInterface */ public function build() { $fs = new FileSystem($this->getScheme(), $this->getStreamWrapper() ?: $this->buildDefaultStreamWrapper(), $this->getNodeFactory() ?: $this->buildDefaultNodeFactory(), $this->getNodeWalker() ?: $this->buildDefaultNodeWalker(), $this->getRegistry() ?: $this->buildDefaultRegistry(), $this->getLogger() ?: $this->buildDefaultLogger()); $root = $fs->get('/'); $factory = $fs->getNodeFactory(); foreach ($factory->buildTree($this->getTree()) as $name => $node) { $root->set($name, $node); } return $fs; }
/** * Test setup. */ protected function setUp() { $this->fs = FileSystem::factory('vfs://'); $this->fs->mount(); \mkdir('vfs://data'); \mkdir('vfs://data/pages'); \file_put_contents(self::simpleFileName, self::simpleFileContent); \file_put_contents(self::titleFileName, self::titleFileContent); \file_put_contents(self::templateFileName, self::templateFileContent); \file_put_contents(self::twigFileName, self::twigFileContent); \file_put_contents(self::redirectFileName, self::redirectFileContent); \file_put_contents(self::markdownFileName, self::markdownFileContent); \file_put_contents(self::mdFileName, self::mdFileContent); \file_put_contents(self::textileFileName, self::textileFileContent); \file_put_contents(self::htmlFileName, self::htmlFileContent); \file_put_contents(self::htmFileName, self::htmFileContent); \file_put_contents(self::txtMarkdownFileName, self::txtMarkdownFileContent); \file_put_contents(self::txtMdFileName, self::txtMdFileContent); \file_put_contents(self::txtTextileFileName, self::txtTextileFileContent); \file_put_contents(self::txtHtmlFileName, self::txtHtmlFileContent); \file_put_contents(self::expiredFileName, self::expiredFileContent); \file_put_contents(self::badExpiredFileName, self::badExpiredFileContent); \file_put_contents(self::notExpiredFileName, self::notExpiredFileContent); \file_put_contents(self::expiredRedirectFileName, self::expiredRedirectFileContent); \file_put_contents(self::notExpiredRedirectFileName, self::notExpiredRedirectFileContent); }
/** * Retrieve global filesystem instance * @return Vfs\FileSystem */ public static function getFileSystem() { if (empty(self::$fileSystem)) { self::$fileSystem = FileSystem::factory('recompilr://'); } return self::$fileSystem; }
/** * Test setup. */ protected function setUp() { $this->fs = FileSystem::factory('vfs://'); $this->fs->mount(); \mkdir('vfs://data'); \mkdir('vfs://data/pages'); \file_put_contents(self::fileName, self::fileContent); }
public function testFixFlow() { $fs = FileSystem::factory(); $fs->mount(); $fs->get('/')->add('some.php', new File(self::getFixture('camel-case-fail'))); $exitCode = $this->app->run(['<path>' => 'vfs://some.php', '--fix' => true, '--debug' => false]); $this->assertEquals($exitCode, 0); $this->assertContains('fixed', $this->buffer->get()); $this->assertContains('Code is valid!', $this->buffer->get()); }
/** * Test setup. */ protected function setUp() { $this->fs = FileSystem::factory('vfs://'); $this->fs->mount(); \mkdir('vfs://data'); \mkdir('vfs://data/pages'); \file_put_contents('vfs://data/pages/default.md', '# Test'); \file_put_contents('vfs://data/pages/test1.md', '# Test'); \file_put_contents('vfs://data/pages/test1.markdown', '# Test'); \file_put_contents('vfs://data/pages/test1.textile', 'h1. Test'); \file_put_contents('vfs://data/pages/test1.html', '<h1>Test</h1>'); \file_put_contents('vfs://data/pages/test1.htm', '<h1>Test</h1>'); \file_put_contents('vfs://data/pages/test1.txt', "Test\n===="); }
function initialize() { $this->attach('connect', function ($client) { $wrappers = []; foreach ($this->wrappers as $w) { $wrappers[] = ['id' => $w->getID(), 'name' => $w->getName()]; } // informs client of available streams $client->send(new Protocol\ListStreams(), ['streams' => $wrappers]); }); $streams = ['amu', 'aud', 'chf', 'eur', 'gbp', 'jpy', 'usd']; $fs = FileSystem::factory('qtcp://'); foreach ($streams as $name) { file_put_contents('qtcp:///stream_' . $name . '.dat', rand(0, 1000)); $file = new qio\File('qtcp:///stream_' . $name . '.dat'); $w = new qtcp\Stream\Wrapper($name, $file); $this->wrappers->insert($w->getID(), $w); } /* * This timer will open up every source file * and randomly increase/decrease value plus or minus 20 */ $this->clock->addTimer(new qtcp\Application\BubbleTimer(0.01, function () use($file) { foreach ($this->wrappers as $wrapper) { $stream = $wrapper->createStream(\qio\Stream\Mode::ReadWrite); $reader = $wrapper->createReader($stream); if (!$stream->isOpen()) { $stream->open(); } $oldValue = (int) $reader->readAll(); $writer = $wrapper->createWriter($stream); $newValue = $oldValue + round(rand(-20, 20)); if ($newValue < 0) { $newValue = 0; } if ($newValue > 1000) { $newValue = 1000; } $stream->rewind(); $writer->write($newValue); $stream->close(); } })); }
<?php /* * This file is part of VFS * * Copyright (c) 2014 Andrew Lawson <http://adlawson.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Vfs\FileSystem; require __DIR__ . '/../vendor/autoload.php'; FileSystem::factory('eval://'); file_put_contents('eval://foo.php', <<<'EOF' <?php class Foo { protected $name; public function __construct($name) { $this->name = $name; } public function getName() { return $this->name; } } EOF
public function setUp() { $this->fs = VirtualFileSystem::factory('vfs://'); $this->fs->mount(); }
public static function tearDownAfterClass() { static::$fileSystem->unmount(); }
/** * @AfterScenario * * @param AfterScenarioScope $scope */ public function afterScenario(AfterScenarioScope $scope) { $this->fileSystem->unmount(); }