当前位置: 首页>>代码示例>>PHP>>正文


PHP vfs\vfsStream类代码示例

本文整理汇总了PHP中org\bovigo\vfs\vfsStream的典型用法代码示例。如果您正苦于以下问题:PHP vfsStream类的具体用法?PHP vfsStream怎么用?PHP vfsStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了vfsStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _setUpFiles

 /**
  * {@inheritdoc}
  */
 public function _setUpFiles($structure = NULL)
 {
     $structure = $structure ?: ['tmp' => []];
     $this->root = vfsStream::setup('root', 0777, $structure);
     $this->adapter = new TempFileAdapter($this->root->url() . '/tmp/', 'bmtest_');
     $this->manager = new TempFileManager($this->adapter);
 }
开发者ID:Wylbur,项目名称:gj,代码行数:10,代码来源:TempFileConsumerTestTrait.php

示例2: testGeneratesTestCodeCorrectly

 /**
  * @param string $className
  * @dataProvider provider
  */
 public function testGeneratesTestCodeCorrectly($className)
 {
     $generatedFile = vfsStream::url('root') . '/' . $className . 'Test.php';
     $generator = new TestGenerator($className, __DIR__ . '/_fixture/_input/' . $className . '.php', $className . 'Test', $generatedFile);
     $generator->write();
     $this->assertStringMatchesFormatFile(__DIR__ . '/_fixture/_expected/' . $className . 'Test.php', file_get_contents($generatedFile));
 }
开发者ID:BelkaB,项目名称:tangara-server,代码行数:11,代码来源:FileControllerTest.php

示例3:

 function it_creates_internal_io_factory_with_vfs_stream()
 {
     $this->serviceContainer->get('ecomdev.phpspec.magento_di_adapter.vfs')->willReturn(vfsStream::setup('custom_root_dir'));
     $factory = $this->ioFactory();
     $factory->shouldImplement(\Closure::class);
     $factory($this->serviceContainer)->shouldImplement(Io::class);
 }
开发者ID:ecomdev,项目名称:phpspec-magento-di-adapter,代码行数:7,代码来源:ExtensionSpec.php

示例4: testLoadUncovered

 /**
  * We ignore items that are not covered by the map.
  */
 public function testLoadUncovered()
 {
     vfsStream::setup('StaticMapTestLoadUncovered', null, ['a.php' => '<?php']);
     $object = new StaticMap(['A' => vfsStream::url('a.php'), 'B' => vfsStream::url('Covered.php')]);
     $object->load('StaticMapTestLoadUncoveredC_XYZ');
     $this->assertFalse(class_exists('StaticMapTestLoadUncoveredC_XYZ', false));
 }
开发者ID:evoke-php,项目名称:evoke-php,代码行数:10,代码来源:StaticMapTest.php

示例5: provideMutexFactories

 /**
  * Provides Mutex factories.
  *
  * @return callable[][] The mutex factories.
  */
 public function provideMutexFactories()
 {
     $cases = ["NoMutex" => [function () {
         return new NoMutex();
     }], "TransactionalMutex" => [function () {
         $pdo = new \PDO("sqlite::memory:");
         $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         return new TransactionalMutex($pdo);
     }], "FlockMutex" => [function () {
         vfsStream::setup("test");
         return new FlockMutex(fopen(vfsStream::url("test/lock"), "w"));
     }], "SemaphoreMutex" => [function () {
         return new SemaphoreMutex(sem_get(ftok(__FILE__, "a")));
     }], "SpinlockMutex" => [function () {
         $mock = $this->getMockForAbstractClass(SpinlockMutex::class, ["test"]);
         $mock->expects($this->any())->method("acquire")->willReturn(true);
         $mock->expects($this->any())->method("release")->willReturn(true);
         return $mock;
     }], "LockMutex" => [function () {
         $mock = $this->getMockForAbstractClass(LockMutex::class);
         $mock->expects($this->any())->method("lock")->willReturn(true);
         $mock->expects($this->any())->method("unlock")->willReturn(true);
         return $mock;
     }]];
     if (getenv("MEMCACHE_HOST")) {
         $cases["MemcacheMutex"] = [function () {
             $memcache = new Memcache();
             $memcache->connect(getenv("MEMCACHE_HOST"));
             return new MemcacheMutex("test", $memcache);
         }];
         $cases["MemcachedMutex"] = [function () {
             $memcache = new Memcached();
             $memcache->addServer(getenv("MEMCACHE_HOST"), 11211);
             return new MemcachedMutex("test", $memcache);
         }];
     }
     if (getenv("REDIS_URIS")) {
         $uris = explode(",", getenv("REDIS_URIS"));
         $cases["PredisMutex"] = [function () use($uris) {
             $clients = array_map(function ($uri) {
                 return new Client($uri);
             }, $uris);
             return new PredisMutex($clients, "test");
         }];
         $cases["PHPRedisMutex"] = [function () use($uris) {
             $apis = array_map(function ($uri) {
                 $redis = new Redis();
                 $uri = parse_url($uri);
                 if (!empty($uri["port"])) {
                     $redis->connect($uri["host"], $uri["port"]);
                 } else {
                     $redis->connect($uri["host"]);
                 }
                 return $redis;
             }, $uris);
             return new PHPRedisMutex($apis, "test");
         }];
     }
     return $cases;
 }
开发者ID:hyperunknown,项目名称:lock,代码行数:65,代码来源:MutexTest.php

示例6: testLoad

    /**
     * {@inheritdoc}
     */
    public function testLoad()
    {
        $xml = <<<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<mediatypes>
    <mediatype name="mp4" category="video">
        <mimetypes>
            <mimetype>video/mp4</mimetype>
        </mimetypes>
    </mediatype>
    <mediatype name="jpg" category="image">
        <mimetypes>
            <mimetype>image/jpg</mimetype>
            <mimetype>image/jpeg</mimetype>
        </mimetypes>
    </mediatype>
</mediatypes>
EOF;
        vfsStream::setup('root', null, ['types.xml' => $xml]);
        $mediatypes = $this->loader->load(vfsStream::url('root/types.xml'));
        $this->assertCount(2, $mediatypes);
        $this->assertTrue($mediatypes->has('video:mp4'));
        $this->assertSame('mp4', $mediatypes->get('video:mp4')->getName());
        $this->assertSame('video', $mediatypes->get('video:mp4')->getCategory());
        $this->assertCount(1, $mediatypes->get('video:mp4')->getMimetypes());
        $this->assertSame(['video/mp4'], $mediatypes->get('video:mp4')->getMimetypes());
        $this->assertTrue($mediatypes->has('image:jpg'));
        $this->assertSame('jpg', $mediatypes->get('image:jpg')->getName());
        $this->assertSame('image', $mediatypes->get('image:jpg')->getCategory());
        $this->assertCount(2, $mediatypes->get('image:jpg')->getMimetypes());
        $this->assertSame(['image/jpg', 'image/jpeg'], $mediatypes->get('image:jpg')->getMimetypes());
    }
开发者ID:temp,项目名称:media-classifier,代码行数:35,代码来源:XmlLoaderTest.php

示例7: testAnsibleCommandNotExecutableException

 /**
  * @expectedException \ErrorException
  * @covers \Asm\Ansible\Ansible::checkCommand
  * @covers \Asm\Ansible\Ansible::checkDir
  * @covers \Asm\Ansible\Ansible::__construct
  */
 public function testAnsibleCommandNotExecutableException()
 {
     $vfs = vfsStream::setup('/tmp');
     $ansiblePlaybook = vfsStream::newFile('ansible-playbook', 600)->at($vfs);
     $ansibleGalaxy = vfsStream::newFile('ansible-galaxy', 444)->at($vfs);
     $ansible = new Ansible($this->getProjectUri(), $ansiblePlaybook->url(), $ansibleGalaxy->url());
 }
开发者ID:Kron0S,项目名称:php-ansible,代码行数:13,代码来源:AnsibleTest.php

示例8: setUp

 /**
  * set up test environment
  */
 public function setUp()
 {
     $root = vfsStream::setup();
     $this->file = vfsStream::newFile('foo.txt')->withContent("bar\nbaz")->at($root);
     $this->underlyingStream = fopen($this->file->url(), 'rb+');
     $this->stream = new Stream($this->underlyingStream);
 }
开发者ID:stubbles,项目名称:stubbles-peer,代码行数:10,代码来源:StreamTest.php

示例9: array

 /**
  * This test creates an extension based on a JSON file, generated
  * with version 1.0 of the ExtensionBuilder and compares all
  * generated files with the originally created ones
  * This test should help, to find compatibility breaking changes
  *
  * @test
  */
 function generateExtensionFromVersion3Configuration()
 {
     $this->configurationManager = $this->getMock($this->buildAccessibleProxy('EBT\\ExtensionBuilder\\Configuration\\ConfigurationManager'), array('dummy'));
     $this->extensionSchemaBuilder = $this->objectManager->get('EBT\\ExtensionBuilder\\Service\\ExtensionSchemaBuilder');
     $testExtensionDir = $this->fixturesPath . 'TestExtensions/test_extension_v3/';
     $jsonFile = $testExtensionDir . \EBT\ExtensionBuilder\Configuration\ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE;
     if (file_exists($jsonFile)) {
         // compatibility adaptions for configurations from older versions
         $extensionConfigurationJSON = json_decode(file_get_contents($jsonFile), TRUE);
         $extensionConfigurationJSON = $this->configurationManager->fixExtensionBuilderJSON($extensionConfigurationJSON, FALSE);
     } else {
         $extensionConfigurationJSON = array();
         $this->fail('JSON file not found');
     }
     $this->extension = $this->extensionSchemaBuilder->build($extensionConfigurationJSON);
     $this->fileGenerator->setSettings(array('codeTemplateRootPath' => PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/', 'extConf' => array('enableRoundtrip' => '0')));
     $newExtensionDir = vfsStream::url('testDir') . '/';
     $this->extension->setExtensionDir($newExtensionDir . 'test_extension/');
     $this->fileGenerator->build($this->extension);
     $referenceFiles = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath(array(), $testExtensionDir);
     foreach ($referenceFiles as $referenceFile) {
         $createdFile = str_replace($testExtensionDir, $this->extension->getExtensionDir(), $referenceFile);
         if (!in_array(basename($createdFile), array('ExtensionBuilder.json'))) {
             $referenceFileContent = str_replace(array('2011-08-11T06:49:00Z', '2011-08-11', '###YEAR###', '2014'), array(date('Y-m-d\\TH:i:00\\Z'), date('Y-m-d'), date('Y'), date('Y')), file_get_contents($referenceFile));
             $this->assertFileExists($createdFile, 'File ' . $createdFile . ' was not created!');
             // do not compare files that contain a formatted DateTime, as it might have changed between file creation and this comparison
             if (strpos($referenceFile, 'xlf') === FALSE && strpos($referenceFile, 'yaml') === FALSE) {
                 $originalLines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $referenceFileContent, TRUE);
                 $generatedLines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, file_get_contents($createdFile), TRUE);
                 $this->assertEquals($originalLines, $generatedLines, 'File ' . $createdFile . ' was not equal to original file.');
             }
         }
     }
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:42,代码来源:CompatibilityTest.php

示例10: testWriteFailsWhenThereIsAProblemWithSymfonyYamlDumper

 public function testWriteFailsWhenThereIsAProblemWithSymfonyYamlDumper()
 {
     $yamlWriterProvider = new YamlWriterProvider($this->mockWriter);
     $this->mockWriter->expects($this->once())->method('dump')->with(array('result' => false))->willThrowException(new DumpException());
     $this->setExpectedException('JGimeno\\TaskReporter\\Infrastructure\\Exception\\YamlProviderException');
     $yamlWriterProvider->write(vfsStream::url('settings/config.yml'), array('result' => false));
 }
开发者ID:destebang,项目名称:taskreporter-1,代码行数:7,代码来源:YamlWriterProviderTest.php

示例11: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->dir = vfsStream::setup();
     $dir = $this->dir;
     $tempDir = vfsStream::url($dir->getName()) . '/';
     $this->media = $this->getMock('\\Oryzone\\MediaStorage\\Model\\MediaInterface');
     $this->media->expects($this->any())->method('getContext')->will($this->returnValue('default'));
     $this->media->expects($this->any())->method('getName')->will($this->returnValue('sample'));
     $this->media->expects($this->any())->method('getContent')->will($this->returnValue('http://vimeo.com/56974716'));
     $this->media->expects($this->any())->method('getMetaValue')->will($this->returnValueMap(array(array('id', null, '56974716'))));
     $this->variant = $this->getMock('\\Oryzone\\MediaStorage\\Variant\\VariantInterface');
     $this->variant->expects($this->any())->method('getName')->will($this->returnValue('default'));
     $this->variant->expects($this->any())->method('getOptions')->will($this->returnValue(array('width' => 50, 'height' => 30, 'resize' => 'stretch')));
     $this->variant->expects($this->any())->method('getMetaValue')->will($this->returnValueMap(array(array('width', null, 50), array('height', null, 30))));
     $image = $this->getMock('\\Imagine\\Image\\ImageInterface');
     $image->expects($this->any())->method('save')->will($this->returnCallback(function ($destFile) use($dir) {
         $temp = vfsStream::newFile(basename($destFile));
         $dir->addChild($temp);
         return true;
     }));
     $imagine = $this->getMock('\\Imagine\\Image\\ImagineInterface');
     $imagine->expects($this->any())->method('open')->will($this->returnValue($image));
     $downloader = $this->getMock('\\Oryzone\\MediaStorage\\Downloader\\DownloaderInterface');
     $downloader->expects($this->any())->method('download')->will($this->returnCallback(function ($url, $destination) use($dir) {
         $temp = vfsStream::newFile(basename($destination));
         $temp->setContent(file_get_contents(__DIR__ . '/../fixtures/images/sample.jpg'));
         $dir->addChild($temp);
         return true;
     }));
     $videoService = $this->getMock('\\Oryzone\\MediaStorage\\Integration\\Video\\VideoServiceInterface');
     $this->provider = new VimeoProvider($tempDir, $imagine, $videoService, $downloader);
 }
开发者ID:jmcclell,项目名称:OryzoneMediaStorage,代码行数:36,代码来源:VimeoProviderTest.php

示例12: setUp

 /**
  * Setup the test
  */
 public function setUp()
 {
     vfsStream::setup('root', null, array('test' => 'testing'));
     $this->file = vfsStream::url('root/test');
     $this->properties = $this->getMock('\\Pants\\Property\\Properties');
     $this->task = new Copy($this->properties);
 }
开发者ID:toxygene,项目名称:pants,代码行数:10,代码来源:CopyTest.php

示例13: testTransform

    /**
     * @covers phpDocumentor\Plugin\Core\Transformer\Writer\CheckStyle::transform
     */
    public function testTransform()
    {
        $transformer = m::mock('phpDocumentor\\Transformer\\Transformation');
        $transformer->shouldReceive('getTransformer->getTarget')->andReturn(vfsStream::url('CheckStyleTest'));
        $transformer->shouldReceive('getArtifact')->andReturn('artifact.xml');
        $fileDescriptor = m::mock('phpDocumentor\\Descriptor\\FileDescriptor');
        $projectDescriptor = m::mock('phpDocumentor\\Descriptor\\ProjectDescriptor');
        $projectDescriptor->shouldReceive('getFiles->getAll')->andReturn(array($fileDescriptor));
        $error = m::mock('phpDocumentor\\Descriptor\\Validator\\Error');
        $fileDescriptor->shouldReceive('getPath')->andReturn('/foo/bar/baz');
        $fileDescriptor->shouldReceive('getAllErrors->getAll')->andReturn(array($error));
        $error->shouldReceive('getLine')->andReturn(1234);
        $error->shouldReceive('getCode')->andReturn(5678);
        $error->shouldReceive('getSeverity')->andReturn('error');
        $error->shouldReceive('getContext')->andReturn('myContext');
        $this->translator->shouldReceive('translate')->with('5678')->andReturn('5678 %s');
        // Call the actual method
        $this->checkStyle->transform($projectDescriptor, $transformer);
        // Assert file exists
        $this->assertTrue($this->fs->hasChild('artifact.xml'));
        // Inspect XML
        $xml = <<<XML
<?xml version="1.0"?>
<checkstyle version="1.3.0">
  <file name="/foo/bar/baz">
    <error line="1234" severity="error" message="5678 myContext" source="phpDocumentor.file.5678"/>
  </file>
</checkstyle>
XML;
        $expectedXml = new \DOMDocument();
        $expectedXml->loadXML($xml);
        $actualXml = new \DOMDocument();
        $actualXml->load(vfsStream::url('CheckStyleTest/artifact.xml'));
        $this->assertEqualXMLStructure($expectedXml->firstChild, $actualXml->firstChild, true);
    }
开发者ID:bbonnesoeur,项目名称:phpDocumentor2,代码行数:38,代码来源:CheckStyleTest.php

示例14: setUp

 /**
  */
 public function setUp()
 {
     ComposerUtility::flushCaches();
     vfsStream::setup('Packages');
     $this->mockPackageManager = $this->getMockBuilder(\Neos\Flow\Package\PackageManager::class)->disableOriginalConstructor()->getMock();
     ObjectAccess::setProperty($this->mockPackageManager, 'composerManifestData', array(), true);
 }
开发者ID:neos,项目名称:flow-development-collection,代码行数:9,代码来源:PackageTest.php

示例15: setUp

 protected function setUp()
 {
     $file = vfsStream::newFile('template');
     $this->fileSystem = vfsStream::setup();
     $this->fileSystem->addChild($file);
     $this->filePath = $file->url();
 }
开发者ID:bazzline,项目名称:php_component_template,代码行数:7,代码来源:FileBasedTemplateTest.php


注:本文中的org\bovigo\vfs\vfsStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。