Inheritance: extends vfsStreamAbstractContent, implements org\bovigo\vfs\vfsStreamContainer
 protected function setUp()
 {
     $file = vfsStream::newFile('template');
     $this->fileSystem = vfsStream::setup();
     $this->fileSystem->addChild($file);
     $this->filePath = $file->url();
 }
 /**
  * @depends testInstanceOf
  */
 public function testWriteIsWritingYamlIntoFile()
 {
     $yamlWriterProvider = new YamlWriterProvider($this->mockWriter);
     $this->mockWriter->expects($this->once())->method('dump')->with(array('result' => false))->willReturn('result: false');
     $yamlWriterProvider->write(vfsStream::url('settings/config.yml'), array('result' => false));
     $this->assertTrue($this->root->hasChild('settings/config.yml'));
 }
 /**
  * @test
  */
 public function shouldUpdateVersionInEmConf()
 {
     $service = new EmConfService($this->root->url(), 'extension_manager');
     $service->updateVersion('47.11.4711');
     $service->write();
     $this->assertRegExp('~\'version\' => \'47\\.11\\.4711\'~', $this->emConf->getContent());
 }
 public function testConstruct()
 {
     $this->assertFileExists($this->configDir->url() . DIRECTORY_SEPARATOR . 'test');
     unset($configHandler);
     new ConfigFileHandler('test-process', $this->configDirPath);
     $this->assertEquals(['root' => ['test' => []]], vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure());
 }
Beispiel #5
0
 /**
  * @test
  *
  * @covers Cocur\NQM\QueryLoader\FilesystemQueryLoader::getQuery()
  * @covers Cocur\NQM\QueryLoader\FilesystemQueryLoader::getQueryFilename()
  */
 public function getQueryShouldReturnQuery()
 {
     $file = new vfsStreamFile('foobar.sql');
     $file->setContent('SELECT * FROM table;');
     $this->rootDir->addChild($file);
     $this->assertEquals('SELECT * FROM table;', $this->loader->getQuery('foobar'));
 }
 /**
  * @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'));
 }
 public function testNonExistent()
 {
     $url = $this->_root->url() . '/test';
     $validator = new DirectoryWritable();
     $this->assertFalse($validator->isValid($url));
     $this->assertEquals(array(DirectoryWritable::DIRECTORY => "'{$url}' ist kein Verzeichnis oder nicht zugänglich"), $validator->getMessages());
 }
 public function testNonExistent()
 {
     $url = $this->_root->url() . '/test';
     $validator = new FileReadable();
     $this->assertFalse($validator->isValid($url));
     $this->assertEquals(array(FileReadable::FILE => "'{$url}' ist keine Datei oder nicht zugänglich"), $validator->getMessages());
 }
Beispiel #9
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');
 }
 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());
 }
 /**
  * @expectedException RuntimeException
  */
 public function testShouldThrowExceptionWhenDeletionNotPermitted()
 {
     $this->root->chmod(0555);
     $this->root->getChild('testfile2')->chmod(0555);
     $localDelete = new DefaultDelete($this->root->url() . '/testfile2');
     $localDelete->execute();
 }
 /**
  */
 public function testFustyRequest_ValidateUpload()
 {
     //// Setup test
     $firstChunk = vfsStream::newFile('temp_file');
     $firstChunk->setContent('1234567890');
     $this->vfs->addChild($firstChunk);
     $fileInfo = new \ArrayObject(array('size' => 10, 'error' => UPLOAD_ERR_OK, 'tmp_name' => $firstChunk->url()));
     $request = new \ArrayObject(array('flowIdentifier' => '13632-prettifyjs', 'flowFilename' => 'prettify.js', 'flowRelativePath' => 'home/prettify.js'));
     $fustyRequest = new FustyRequest($request, $fileInfo);
     $config = new Config();
     $config->setTempDir($this->vfs->url());
     /** @var File $file */
     $file = $this->getMock('Flow\\File', array('_move_uploaded_file'), array($config, $fustyRequest));
     /** @noinspection PhpUndefinedMethodInspection */
     $file->expects($this->once())->method('_move_uploaded_file')->will($this->returnCallback(function ($filename, $destination) {
         return rename($filename, $destination);
     }));
     //// Actual test
     $this->assertTrue($file->validateChunk());
     $this->assertFalse($file->validateFile());
     $this->assertTrue($file->saveChunk());
     $this->assertTrue($file->validateFile());
     $path = $this->vfs->url() . DIRECTORY_SEPARATOR . 'new';
     $this->assertTrue($file->save($path));
     $this->assertEquals(10, filesize($path));
 }
 public function testCreate_WhenPatternHasLastOnFile_ThrowsException()
 {
     vfsStream::newFile('file.csv')->at($this->root);
     $pathToFile = $this->root->url() . '/file.csv';
     $this->setExpectedException('\\InvalidArgumentException');
     $this->getFileNameGenerator($pathToFile . ':last')->getGeneratedFileName();
 }
 protected function createVendorDirectory(vfsStreamDirectory $rootDirectory)
 {
     $directory = new vfsStreamDirectory('vendor');
     $rootDirectory->addChild($directory);
     $directory->addChild(new vfsStreamFile('autoload.php'));
     $subDirectory = new vfsStreamDirectory('composer');
     $directory->addChild($subDirectory);
     $subDirectory->addChild(new vfsStreamFile('autoload_classmap.php'));
     $subDirectory->addChild(new vfsStreamFile('autoload_namespaces.php'));
     $subDirectory->addChild(new vfsStreamFile('autoload_psr4.php'));
     $subDirectory->addChild(new vfsStreamFile('autoload_real.php'));
     $subDirectory->addChild(new vfsStreamFile('ClassLoader.php'));
     $subDirectory->addChild(new vfsStreamFile('installed_paths.php'));
     $subDirectory->addChild(new vfsStreamFile('installed.json'));
     $subDirectory = new vfsStreamDirectory('psr');
     $directory->addChild($subDirectory);
     $secondLevelSubDirectory = new vfsStreamDirectory('log');
     $subDirectory->addChild($secondLevelSubDirectory);
     $secondLevelSubDirectory->addChild(new vfsStreamFile('.gitignore'));
     $secondLevelSubDirectory->addChild(new vfsStreamFile('composer.json'));
     $secondLevelSubDirectory->addChild(new vfsStreamFile('LICENSE'));
     $secondLevelSubDirectory->addChild(new vfsStreamFile('README.md'));
     $thirdLevelSubDirectory = new vfsStreamDirectory('Psr');
     $secondLevelSubDirectory->addChild($thirdLevelSubDirectory);
     $fourthLevelSubDirectory = new vfsStreamDirectory('Log');
     $thirdLevelSubDirectory->addChild($fourthLevelSubDirectory);
     $fourthLevelSubDirectory->addChild(new vfsStreamFile('InvalidArgumentException.php'));
     $fourthLevelSubDirectory->addChild(new vfsStreamFile('LoggerInterface.php'));
     $fourthLevelSubDirectory->addChild(new vfsStreamFile('LogLevel.php'));
     $fourthLevelSubDirectory->addChild(new vfsStreamFile('NullLogger.php'));
 }
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->root = vfsStream::setup();
     $this->root->addChild(new vfsStreamFile('1.png'));
     $this->root->addChild(new vfsStreamFile('2.jpg'));
     $this->root->addChild(new vfsStreamFile('3.jpeg'));
 }
Beispiel #16
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);
 }
 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'));
 }
Beispiel #18
0
 public function testOutputDirNotFound()
 {
     $dir = $this->output_dir->url('thumbs');
     $service = new ImageService($this->imanee, $this->source_dir, $dir . '/test', new Filesystem());
     // test a valid resource
     $thumbnail = $service->thumbnail('valid.jpg', 100, 100, false);
     $this->assertContains('-100x100.jpeg', $thumbnail);
 }
 protected function setUp()
 {
     $this->root = new vfsStreamDirectory('test');
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot($this->root);
     $this->responder = new StaticHtmlFileResponder($this->root->url(), 'file');
     $this->response = new Response();
 }
 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()));
 }
 protected function createTestProject()
 {
     $testDir = self::$tmpName = tempnam(self::$root->url(), '');
     unlink($testDir);
     mkdir($testDir);
     file_put_contents($testDir . '/' . Config::PLATFORM_CONFIG, 'name: phpunit');
     chdir($testDir);
 }
 public function testCreateTmpDir()
 {
     $workingDirectory = $this->workingDirectoryFactory->createTmpDir(array(), array());
     $workingDirectoryPath = $workingDirectory->getPath();
     $this->assertNotEquals($this->storageDir->url(), $workingDirectoryPath);
     $this->assertEquals($this->storageDir->url(), dirname($workingDirectoryPath));
     $this->assertNotEmpty(basename($workingDirectoryPath));
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->provider = new FileProvider();
     $this->dir = vfsStream::setup('root');
     $file = vfsStream::newFile('test');
     $file->write('some content');
     $this->dir->addChild($file);
 }
 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()));
 }
 public function testNoIncludeFile()
 {
     /*
      * include file not found means output + empty $packages
      */
     $this->root->removeChild('include');
     $this->assertEmpty($this->selection->load());
 }
 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 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 setUp()
 {
     $this->mockLockDirectory = vfsStream::setup('LockPath');
     $this->mockLockFile = vfsStream::newFile(md5(FLOW_PATH_ROOT) . '_Flow.lock')->at($this->mockLockDirectory);
     $this->mockLockFlagFile = vfsStream::newFile(md5(FLOW_PATH_ROOT) . '_FlowIsLocked')->at($this->mockLockDirectory);
     $this->lockManager = $this->getMockBuilder(LockManager::class)->setMethods(['getLockPath', 'doExit'])->disableOriginalConstructor()->getMock();
     $this->lockManager->expects($this->atLeastOnce())->method('getLockPath')->will($this->returnValue($this->mockLockDirectory->url() . '/'));
     $this->lockManager->__construct();
 }
 public function testItLoadsItemsIntoProcessor()
 {
     $index = $this->createIndex();
     $index->expects($this->once())->method('getHandleIncludes')->with('handle_one')->willReturn(array(Stream::url($this->fileSystem->path() . '/handle_one_file1.php'), Stream::url($this->fileSystem->path() . '/handle_one_file2.php')));
     $processor = $this->createProcessor();
     $processor->expects($this->exactly(3))->method('addItem')->id('addItem')->withConsecutive(array($this->equalTo(new RemoveItem('handle_one_block_one'))), array($this->equalTo(new RemoveItem('handle_one_block_two'))), array($this->equalTo(new RemoveItem('handle_one_block_three'))))->willReturnSelf();
     $processor->expects($this->once())->method('addItemRelation')->after('addItem')->with($this->equalTo(new RemoveItem('handle_one_block_three')), 'handle_one_block_three')->willReturnSelf();
     $this->assertSame($this->loader, $this->loader->loadIntoProcessor('handle_one', $processor, $index));
 }
 /**
  * @Given /^the model generator for namespace "([^"]*)"$/
  */
 public function theModelGeneratorForNamespace($namespace)
 {
     if (isset($this->vfs)) {
         unset($this->vfs);
     }
     $this->vfs = vfsStream::setup('root');
     spl_autoload_register([$this, 'autoload'], false);
     $this->generator = new ModelGenerator($this->vfs->url(), $namespace);
 }