Пример #1
0
 /**
  * Retrieve global filesystem instance
  * @return Vfs\FileSystem
  */
 public static function getFileSystem()
 {
     if (empty(self::$fileSystem)) {
         self::$fileSystem = FileSystem::factory('recompilr://');
     }
     return self::$fileSystem;
 }
Пример #2
0
 /**
  * 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);
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
 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());
 }
Пример #5
0
 /**
  * Set up fixture test folders and files
  *
  * @throws \Exception
  * @return void
  */
 public static function setUpBeforeClass()
 {
     static::$fileSystem = FileSystem::factory('vfs://');
     static::$fileSystem->mount();
     $testPaths = ['/base/sub/test', '/base/sub/sub/test'];
     // Setup some files we test against
     foreach ($testPaths as $path) {
         mkdir('vfs://' . $path, 0777, true);
         touch('vfs://' . $path . DIRECTORY_SEPARATOR . 'TestClass.php');
     }
 }
Пример #6
0
 /**
  * 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====");
 }
Пример #7
0
 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();
         }
     }));
 }
Пример #8
0
<?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
Пример #9
0
 public function setUp()
 {
     $this->fs = VirtualFileSystem::factory('vfs://');
     $this->fs->mount();
 }