當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。