getChild() 공개 메소드

returns the child with the given name
public getChild ( string $name ) : org\bovigo\vfs\vfsStreamContent
$name string
리턴 org\bovigo\vfs\vfsStreamContent
 /**
  * @expectedException RuntimeException
  */
 public function testShouldThrowExceptionWhenDeletionNotPermitted()
 {
     $this->root->chmod(0555);
     $this->root->getChild('testfile2')->chmod(0555);
     $localDelete = new DefaultDelete($this->root->url() . '/testfile2');
     $localDelete->execute();
 }
예제 #2
0
 function getImageFolder()
 {
     $this->vfsRoot = vfsStream::setup('root');
     mkdir(vfsStream::url('root') . '/images');
     vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/source', $this->vfsRoot->getChild('images'));
     return vfsStream::url('root');
 }
예제 #3
0
 function it_should_do_multiple_to_registry()
 {
     $this->pushImage(vfsStream::url('system/docker/build/buildscript.sh'), 'registry/library/ubuntu:14.04');
     $this->pushImage(vfsStream::url('system/docker/build/buildscript.sh'), 'registry/library/ubuntu:15.04');
     $buildScript = $this->root->getChild('docker/build/buildscript.sh');
     \PHPUnit_Framework_Assert::assertEquals("#!/usr/bin/env bash\ndocker push registry/library/ubuntu:14.04 \\\n&& docker push registry/library/ubuntu:15.04", $buildScript->getContent());
 }
예제 #4
0
 /**
  * @expectedException \EBT\ConfigLoader\Exception\InvalidArgumentException
  * @expectedExceptionMessage not readable
  */
 public function testLoadFileNotReadable()
 {
     $this->root->addChild(vfsStream::newFile('file1'));
     // make sure is not readable
     $this->root->getChild('file1')->chown('testuser')->chgrp('testuser')->chmod(0750);
     (new JsonFileLoader())->load(vfsStream::url('test/file1'));
 }
예제 #5
0
 public function testForReadingWithOptionalKeyParameterConfigFile()
 {
     $configFile = vfsStream::newFile('config.inc.php');
     $configFile->setContent('<?php return ["primary-key"=>["test-key"=>"test-value"]];');
     $this->root->addChild($configFile);
     $configFileReading = new ConfigFileReader($this->root->getChild('config.inc.php')->url());
     $this->assertEquals(['test-key' => 'test-value'], $configFileReading->getConfiguration('primary-key'));
 }
예제 #6
0
 public function testSavingConfig()
 {
     $this->object->setGeneratorDirectory('generator/test/dir');
     $this->assertTrue($this->filesystem->hasChild('.phpteda'));
     $actualConfiguration = unserialize($this->filesystem->getChild('.phpteda')->getContent());
     $expectedConfiguration = array('GeneratorDirectory' => 'generator/test/dir');
     $this->assertEquals($expectedConfiguration, $actualConfiguration);
 }
예제 #7
0
 protected function pathToUrl($path = '')
 {
     //@todo Consider adding hasChild() test and throw exception if test fails?
     if ($this->root->hasChild(ltrim($path, '/'))) {
         return $this->root->getChild(ltrim($path, '/'))->url();
     }
     return $this->root->url() . $path;
 }
 public function testIsFile()
 {
     $this->root->addChild(new vfsStreamDirectory('assets'));
     $dir = $this->root->getChild('assets');
     $file = vfsStream::newFile('foo.txt')->withContent('foo')->at($this->root);
     $this->assertFalse($this->trait->isFile($dir->url()));
     $this->assertTrue($this->trait->isFile($file->url()));
 }
 public function testItSavesTypeClassFiles()
 {
     $this->sut->save(FooBarType::class, 'foobar_type_class_content');
     $filename = base64_encode(FooBarType::class) . '.php';
     $this->assertTrue($this->root->hasChild($filename));
     $child = $this->root->getChild($filename);
     $this->assertEquals('<?php foobar_type_class_content', file_get_contents($child->url()));
 }
예제 #10
0
 public function testEnumTypeDefinitionsFromBundles()
 {
     $this->container->setParameter('kernel.bundles', ['FooBundle', 'BarBundle']);
     require_once $this->root->getChild('src/FooBundle/FooBundle.php')->url();
     require_once $this->root->getChild('src/BarBundle/BarBundle.php')->url();
     $this->container->compile();
     $this->assertAddTypeCalls(['foobar' => FooBarType::class, 'onetwo' => OneTwoType::class, 'threefour' => OneTwoType::class]);
 }
 public function testFileIsOnDestinationAfterShift()
 {
     $shift = new DefaultShift($this->root->url() . '/testfile1', $this->root->url() . '/testfile1Shifted');
     $shift->execute();
     /** @var vfsStreamFile $shiftedFile */
     $shiftedFile = $this->root->getChild('testfile1Shifted');
     $this->assertNotNull($shiftedFile);
     $this->assertEquals('testfile1Shifted', $shiftedFile->getName());
     $this->assertEquals('TestContent', $shiftedFile->getContent());
 }
 public function testShouldBeAbleToCopyFile()
 {
     $this->root->addChild(vfsStream::newFile('testfile1copy')->setContent('TestContent'));
     $copy = new DefaultCopy($this->root->url() . '/testfile1', $this->root->url() . '/testfile1copy');
     $copy->execute();
     /** @var vfsStreamFile $copiedFile */
     $copiedFile = $this->root->getChild('testfile1copy');
     $this->assertEquals('testfile1copy', $copiedFile->getName());
     $this->assertEquals('TestContent', $copiedFile->getContent());
 }
예제 #13
0
 public function testUpload()
 {
     $this->assertTrue($this->vfs->getChild('tmp')->hasChild('foo.txt'));
     $this->assertFalse($this->vfs->getChild('uploads')->hasChild('bar'));
     $input = new File('foo.txt', vfsStream::url('root/tmp/foo.txt'));
     $id = $this->uploads->upload($input);
     $this->assertFalse($this->vfs->hasChild('foo.txt'));
     $parts = explode('/', $id);
     $leaf = array_pop($parts);
     $child = $this->vfs->getChild('uploads');
     foreach ($parts as $part) {
         $this->assertTrue($child->hasChild($part));
         $child = $child->getChild($part);
     }
     $this->assertTrue($child->hasChild($leaf));
 }
예제 #14
0
 public function testNotifyBatch()
 {
     $packagesBuilder = new PackagesBuilder(new NullOutput(), vfsStream::url('build'), ['notify-batch' => 'http://localhost:54715/notify', 'repositories' => [['type' => 'composer', 'url' => 'http://localhost:54715']], 'require' => ['vendor/name' => '*']], false);
     $packagesBuilder->dump(self::createPackages(1));
     $packagesJson = JsonFile::parseJson($this->root->getChild('build/packages.json')->getContent());
     $this->assertEquals('http://localhost:54715/notify', $packagesJson['notify-batch']);
 }
예제 #15
0
 protected function given_dump_file_appended($new_mail)
 {
     $dump = $this->tmp_dir->getChild(self::DUMP_FILE);
     /** @var vfsStreamFile $dump */
     $content = $dump->getContent();
     $content .= $new_mail;
     $dump->setContent($content);
 }
예제 #16
0
파일: FSTest.php 프로젝트: VijitCoder/Kira
 /**
  * Проверка перемещения файла
  *
  * Не провожу проверку содержимого, только размеры файлов. Этого достаточно.
  */
 public function test_moveFile()
 {
     $this->assertTrue($this->root->hasChild('some.ext'), 'Целевой файл перед перемещением существует');
     $orgSize = $this->root->getChild('some.ext')->size();
     FS::moveFile($this->rootPath . 'some.ext', $this->rootPath . 'level1/newSome.ext');
     $this->assertFalse($this->root->hasChild('some.ext'), 'Целевой файл после перемещения исчез');
     $this->assertTrue($this->root->hasChild('level1/newSome.ext'), 'Перемещением создан новый файл');
     $this->assertEquals($orgSize, $this->root->getChild('level1/newSome.ext')->size(), 'Размеры файла после перемещения не изменился');
 }
예제 #17
0
 /**
  * @dataProvider dataAbandoned
  *
  * @param bool|string $abandoned
  * @param string $expected
  */
 public function testAbandoned($abandoned, $expected)
 {
     $webBuilder = new WebBuilder(new NullOutput(), vfsStream::url('build'), [], false);
     $webBuilder->setRootPackage($this->rootPackage);
     $this->package->setAbandoned($abandoned);
     $webBuilder->dump([$this->package]);
     $html = $this->root->getChild('build/index.html')->getContent();
     $this->assertRegExp('/Package is abandoned, you should avoid using it/', $html);
     $this->assertRegExp($expected, $html);
 }
예제 #18
0
 public function testFiles()
 {
     $this->root->addChild(new vfsStreamDirectory('tmp'));
     $dir = $this->root->getChild('tmp');
     vfsStream::newFile('foo.txt')->withContent('foo')->at($dir);
     vfsStream::newFile('bar.txt')->withContent('bar')->at($dir);
     $dir->addChild(new vfsStreamDirectory('nested'));
     $dir2 = $dir->getChild('nested');
     vfsStream::newFile('baz.txt')->withContent('baz')->at($dir2);
     $this->assertTrue(in_array('bar.txt', $this->files->files($dir->url())));
     $this->assertTrue(in_array('foo.txt', $this->files->files($dir->url())));
     $this->assertFalse(in_array('foo2.txt', $this->files->files($dir->url())));
 }
예제 #19
0
    /** @test */
    public function sendsMergedContentToShopify()
    {
        // Arrange
        $merge = $this->makeStrategyWithMock();
        $asset = "assets/merge.js";
        $gitRoot = "git/root/assets/merge.js";
        $gitFileContent = file_get_contents(__DIR__ . "/TestFiles/merge.root");
        $localFileContent = file_get_contents(__DIR__ . "/TestFiles/merge.local");
        $remoteFileContent = file_get_contents(__DIR__ . "/TestFiles/merge.remote");
        $expected = <<<CONTENT
Line 1!
Line 2
Line 3
CONTENT;
        // Set local file
        vfs\vfsStream::newFile("merge.js")->withContent($localFileContent)->at($this->fileSystem->getChild("root/theme/assets"));
        // Set git file
        $this->gitFetcherStub->setRevisionContent("HEAD", $gitRoot, $gitFileContent);
        // Set remote file
        $this->shopifyClientMock->expects($this->once())->method("getAsset")->willReturn($remoteFileContent);
        $this->shopifyClientMock->expects($this->once())->method("updateAsset")->with($this->equalTo($asset), $this->equalTo(\ShopFitter\Shopify\AssetType::Text), $this->equalTo($expected), $this->equalTo($this->themeId));
        // Act
        $merge->handle(vfs\vfsStream::url("root/theme/assets/merge.js"), "assets/merge.js", $gitRoot);
    }
예제 #20
0
 public function getMatchers()
 {
     return ['removeFile' => function ($subject, $file) {
         unlink($file);
         return true;
     }, 'havePermissions' => function ($subject, $file, $permissions) {
         $paths = explode('/', $file);
         $item = $this->vfs->getChild(array_shift($paths));
         $currentPermissions = $item->getPermissions();
         foreach ($paths as $path) {
             if (!$path) {
                 continue;
             }
             $item = $item->getChild($path);
             $currentPermissions = $item->getPermissions();
         }
         if ($currentPermissions !== $permissions) {
             throw new NotEqualException(sprintf('File permissions do not match for "%s"', $file), $permissions, $currentPermissions);
         }
         return true;
     }];
 }
예제 #21
0
 function it_returns_constructed_arguments_with_generated_checksum_for_export()
 {
     $file = $this->vfs->getChild('dummy_file1.txt')->url();
     $this->fileChecksum->calculate($file)->willReturn('our_calculated_checksum');
     $this->export()->shouldReturn(['parser' => $this->parser->getWrappedObject(), 'file' => $file, 'checksum' => 'our_calculated_checksum']);
 }
 /**
  * @test
  *
  * @expectedException \Behat\Testwork\Output\Exception\BadOutputPathException
  */
 public function setOutputPathShouldRaiseExceptionIfPathIsNotADirectory()
 {
     vfsStream::newFile('file.exe', 0755)->at($this->validRoot);
     $path = $this->validRoot->getChild('file.exe')->url();
     $printer = $this->createPrinter($path);
 }
 /**
  * @depends testShouldListAllFilesInAFlatStructure
  * @depends testShouldGiveEmptyArrayForEmptyDir
  * @depends testShouldThrowExceptionIfDirNotExists
  * @expectedException RuntimeException
  */
 public function testShouldThrowExceptionWhenPermissionsAreMissingForInitialDir()
 {
     $this->root->getChild('testDir1')->chmod(0333);
     $localScan = new DefaultScan($this->root->url() . '/testDir1');
     $localScan->execute();
 }
예제 #24
0
 /**
  * Gets a virtual file by name.
  *
  * @param $name
  *
  * @return \org\bovigo\vfs\vfsStreamContent
  */
 public function getFileByName($name)
 {
     return $this->vfs->getChild($name);
 }
 public function testHookCheckExceptions()
 {
     $hookManager = new HookManager($this->basePath->getChild('project')->url(), GitHelper::getHooksSourcePath(), 'foo');
     $this->setExpectedException('Exception', '', HookManager::BAD_HOOKS_DESTINATION_PATH_EXCEPTION_CODE);
     $hookManager->checkHooks();
 }
 /**
  * Prepares a non readable file
  * 
  * @return $this
  */
 private function prepareNonReadableFile()
 {
     $this->prepareLayoutFile('<layout></layout>', 'non_readable', 'layout_file.xml');
     $this->fileSystem->getChild('non_readable')->getChild('layout_file.xml')->chmod(0);
     return $this;
 }
예제 #27
0
 public function testDelete()
 {
     $this->assertTrue($this->vfs->getChild('uploads')->hasChild('baz.txt'));
     $this->adapter->delete('baz.txt');
     $this->assertFalse($this->vfs->getChild('uploads')->hasChild('baz.txt'));
 }