public function test_create_token_folder_if_it_does_not_exist()
 {
     $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('tokens'), 'Folder should not exists');
     $tokenizer = $this->instantiateClass('token_filename_retrieve.token', vfsStream::url('testDir/tokens'), $this->token_content, new Filesystem());
     $tokenizer->retrieve();
     $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('tokens'), 'Folder should now exists even if retrieve notes file does not');
 }
Example #2
0
 /**
  * Sets up the test fixture.
  *
  * @return void
  */
 public function setUp()
 {
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory('test'));
     $this->forum = 'test';
     $this->contents = new Forum_Contents(vfsStream::url('test'));
 }
 private function createFile($filePath, $body = 'hello')
 {
     vfsStream::newFile($filePath)->at(vfsStreamWrapper::getRoot());
     $path = vfsStream::url('root/' . $filePath);
     file_put_contents($path, $body);
     return $path;
 }
 public function setUp()
 {
     vfsStreamWrapper::register();
     $root = vfsStream::setup('logs');
     $mockFile = vfsStream::newFile('logging_helper.log')->at($root);
     $root->addChild($mockFile);
 }
Example #5
0
 public function testConstruct()
 {
     // test non existent file
     $nonExistentFilePath = "non/existent/file.php";
     try {
         new ConsoleRunner($nonExistentFilePath, $this->pidFactory, []);
         $this->fail("Should not be able to create a console runner without a console file that exists");
     } catch (RunnerException $e) {
         $this->assertContains($nonExistentFilePath, $e->getMessage());
     }
     // test non executable file
     $nonExecutableFilePath = "nonExecutableFile.php";
     $nonExecutableFile = vfsStream::newFile($nonExecutableFilePath, 00);
     vfsStreamWrapper::getRoot()->addChild($nonExecutableFile);
     $nonExecutableFilePath = $this->getPath($nonExecutableFilePath);
     try {
         new ConsoleRunner($nonExecutableFilePath, $this->pidFactory, []);
         $this->fail("Should not be able to create a console runner without a console file that is executable");
     } catch (RunnerException $e) {
         $this->assertContains($nonExecutableFilePath, $e->getMessage());
     }
     // test valid file
     $consolePath = "console.php";
     $nonExecutableFile = vfsStream::newFile($consolePath, 0444);
     vfsStreamWrapper::getRoot()->addChild($nonExecutableFile);
     $consolePath = $this->getPath($consolePath);
     $runner = new ConsoleRunner($consolePath, $this->pidFactory, []);
     $this->assertAttributeEquals($consolePath, "consolePath", $runner);
 }
Example #6
0
 protected function setFileSystem()
 {
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('build');
     vfsStreamWrapper::setRoot($root);
     return $root;
 }
Example #7
0
 /**
  * Tests the YAML file discovery.
  */
 public function testDiscovery()
 {
     vfsStreamWrapper::register();
     $root = new vfsStreamDirectory('modules');
     vfsStreamWrapper::setRoot($root);
     $url = vfsStream::url('modules');
     mkdir($url . '/test_1');
     file_put_contents($url . '/test_1/test_1.test.yml', 'name: test');
     file_put_contents($url . '/test_1/test_2.test.yml', 'name: test');
     mkdir($url . '/test_2');
     file_put_contents($url . '/test_2/test_3.test.yml', 'name: test');
     // Write an empty YAML file.
     file_put_contents($url . '/test_2/test_4.test.yml', '');
     // Set up the directories to search.
     $directories = array('test_1' => $url . '/test_1', 'test_2' => $url . '/test_1', 'test_3' => $url . '/test_2', 'test_4' => $url . '/test_2');
     $discovery = new YamlDiscovery('test', $directories);
     $data = $discovery->findAll();
     $this->assertEquals(count($data), count($directories));
     $this->assertArrayHasKey('test_1', $data);
     $this->assertArrayHasKey('test_2', $data);
     $this->assertArrayHasKey('test_3', $data);
     $this->assertArrayHasKey('test_4', $data);
     foreach (array('test_1', 'test_2', 'test_3') as $key) {
         $this->assertArrayHasKey('name', $data[$key]);
         $this->assertEquals($data[$key]['name'], 'test');
     }
     $this->assertSame(array(), $data['test_4']);
 }
 protected function setUp()
 {
     parent::setUp();
     vfsStreamWrapper::register();
     $this->vfs = new vfsStreamDirectory('chunks');
     vfsStreamWrapper::setRoot($this->vfs);
 }
Example #9
0
 public function setUp(DiInterface $di = NULL, Config $config = NULL)
 {
     vfsStream::setup('root');
     vfsStream::newFile('file.php')->at(vfsStreamWrapper::getRoot());
     $this->file = vfsStream::url('root/file.php');
     parent::setUp($di, $config);
 }
 /**
  * @test
  * @expectedException \Neos\FluidAdaptor\View\Exception\InvalidTemplateResourceException
  */
 public function getPartialPathAndFilenameThrowsExceptionIfPartialFileIsADirectory()
 {
     vfsStreamWrapper::register();
     mkdir('vfs://MyPartials/NotAFile');
     $this->standaloneView->setPartialRootPath('vfs://MyPartials');
     $this->standaloneView->getTemplatePaths()->getPartialSource('NotAFile');
 }
Example #11
0
 public function testFactoryCreateServiceWithName()
 {
     $this->init(array('logger' => array($this->key => array('path' => vfsStream::url('logs/default.log')))));
     $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('default.log'));
     $this->assertInstanceOf('Zend\\Log\\Logger', $this->factory->createServiceWithName($this->serviceLocator, $this->key, $this->key));
     $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('default.log'));
 }
Example #12
0
 public function setUp()
 {
     $this->rootDir = new vfsStreamDirectory('queries');
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot($this->rootDir);
     $this->loader = new FilesystemQueryLoader($this->rootDir->url());
 }
Example #13
0
 /**
  * Sets up this testcase
  *
  * @return void
  */
 protected function setUp()
 {
     if (!class_exists('org\\bovigo\\vfs\\vfsStreamWrapper')) {
         $this->markTestSkipped('File backend tests are not available with this phpunit version.');
     }
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory('Foo'));
 }
Example #14
0
 /**
  * @test
  */
 public function passwordShouldBeAddToRsaIfPasswordPassed()
 {
     vfsStream::newFile('id_rsa')->at(vfsStreamWrapper::getRoot());
     $authentication = new Rsa('root', vfsStream::url('root/id_rsa'), 'password');
     /** @var \Crypt_RSA $rsa */
     $rsa = $authentication->getAuthentication();
     $this->assertEquals('password', $rsa->password);
 }
Example #15
0
 /**
  * Retrieves the virtual file system path
  *
  * @param string $path The path relative to the root folder
  *
  * @return string
  */
 protected function vfsPath($path = '')
 {
     $root = vfsStreamWrapper::getRoot()->getName();
     if (empty($path)) {
         return vfsStream::url($root);
     }
     return vfsStream::url($root . '/' . $path);
 }
 public function tearDownCacheDir()
 {
     vfsStreamWrapper::register();
     $cacheDir = vfsStream::url('zf2-module-test');
     if (is_dir($cacheDir)) {
         static::rmdir($cacheDir);
     }
 }
 public function setUp()
 {
     $this->buildDir = new vfsStreamDirectory('build');
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot($this->buildDir);
     $this->filesystem = m::mock('Symfony\\Component\\Filesystem\\Filesystem');
     $this->application = new Application($this->getMockKernel());
 }
Example #18
0
 function __construct()
 {
     parent::__construct();
     vfsStreamWrapper::register();
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
     $this->objectMother = new \UnitTest\Lib\ObjectMother($this);
     $this->onCreate();
 }
Example #19
0
 /**
  * PHPUnit cannot add this to code coverage
  *
  * @codeCoverageIgnore
  *
  * @param $swaggerPath
  *
  * @throws \org\bovigo\vfs\vfsStreamException
  */
 public static function initSchemaManager($swaggerPath)
 {
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
     file_put_contents(vfsStream::url('root') . '/swagger.json', json_encode(Yaml::parse(file_get_contents($swaggerPath))));
     self::$schemaManager = new SchemaManager(vfsStream::url('root') . '/swagger.json');
     self::$document = new SwaggerDocument($swaggerPath);
 }
Example #20
0
 public function testCacheWSDLIsWorldWritable()
 {
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp'));
     $SOAP = $this->getMock('SSRS\\Soap\\NTLM', array('setCacheWSDLPermission'), array('http://'));
     $SOAP->expects($this->once())->method('setCacheWSDLPermission')->with($this->equalTo(0666));
     $SOAP->setCachePath(vfsStream::url('tmp/file.wsdl'))->cacheWSDL('$fileContents');
 }
Example #21
0
 public function setUp()
 {
     vfsStreamWrapper::register();
     $root = new vfsStreamDirectory('root');
     vfsStreamWrapper::setRoot($root);
     vfsStream::copyFromFileSystem(__DIR__ . '/../package');
     $this->config = ['version' => '1.0.4', 'configFile' => vfsStream::url('root/app/code/community/Slovenian/LocalePackSl/etc/config.xml'), 'packageFile' => vfsStream::url('root/package.xml')];
 }
Example #22
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = new NlReader();
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('tmp');
     vfsStreamWrapper::setRoot($root);
     $this->file = vfsStream::newFile('items.csv', 0764)->withContent("73-ou-XW46\nApple\n1\na")->at($root);
 }
 /**
  * @test
  *
  * @covers Cocur\Bundle\BuildBundle\Writer\FilesystemWriter::write()
  * @covers Cocur\Bundle\BuildBundle\Writer\FilesystemWriter::getRealName()
  */
 public function writeShouldWriteIfFileIsInDirectory()
 {
     $root = vfsStreamWrapper::getRoot();
     $this->writer->write('/foo', 'Foobar');
     $this->assertTrue($root->hasChild('foo'));
     $this->assertTrue($root->getChild('foo')->hasChild('index.html'));
     $this->assertEquals('Foobar', $root->getChild('foo')->getChild('index.html')->getContent());
 }
 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();
 }
Example #25
0
 public function testExtractPublicKeyToFileWriteError()
 {
     $root = vfsStream::newDirectory('test');
     $root->addChild(vfsStream::newFile('test.key', 00));
     vfsStreamWrapper::setRoot($root);
     $this->setExpectedException('RuntimeException', 'The public key file "vfs://test/test.key" could not be written:');
     $key = $this->helper->createPrivateKey('test');
     $this->helper->extractPublicKeyToFile('vfs://test/test.key', $key, 'test');
 }
Example #26
0
 protected function setFileSystem()
 {
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('build');
     vfsStreamWrapper::setRoot($root);
     $packagesBuilder = new PackagesBuilder(new NullOutput(), vfsStream::url('build'), array('repositories' => array(array('type' => 'composer', 'url' => 'http://localhost:54715')), 'require' => array('vendor/name' => '*')), false);
     $packagesBuilder->dump(array($this->package));
     return $root;
 }
 public function testSetLastUidCorrectly()
 {
     $this->initRoot();
     $file = vfsStream::url('home/lastui.json');
     $lastUidPersistFile = new LastUidPersistFile($file);
     $lastUidPersistFile->setLastUid(12);
     $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('lastui.json'), 'The file is not created');
     $this->assertTrue(file_get_contents($file) == json_encode(array('lastUid' => 12)), 'The file content is not correct');
 }
Example #28
0
 /** @test */
 public function attachPhoto()
 {
     $pic = 'photo.jpg';
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('pics');
     vfsStreamWrapper::setRoot($root);
     vfsStream::newFile($pic)->at($root);
     $this->entry->attachPhoto(vfsStream::url('pics/' . $pic));
     $this->assertTrue($this->entry->hasPhoto());
 }
Example #29
0
 public function testInitWithExistingIdxFile()
 {
     vfsStreamWrapper::getRoot()->addChild(new vfsStreamFile('idxfile.php'));
     $idx = $this->getMock('\\Idephix\\IdephixInterface');
     $idx->output = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface');
     $idx->output->expects($this->exactly(1))->method('writeln')->with("<error>An idxfile.php already exists, generation skipped.</error>");
     $initIdxFile = new InitIdxFile('vfs://root');
     $initIdxFile->setIdephix($idx);
     $initIdxFile->initFile();
 }
Example #30
0
 /**
  * @expectedException        Message\Cog\Config\Exception
  * @expectedExceptionMessage Config file `vfs://config/myconfig.yml` is not readable
  */
 public function testExceptionThrownWhenConfigFileNotReadable()
 {
     vfsStream::setup('config');
     vfsStream::newFile('myconfig.yml', 0333)->at(vfsStreamWrapper::getRoot());
     $env = new FauxEnvironment();
     $env->set('staging');
     $loader = new Loader(vfsStream::url('config'), $env);
     $registry = new NonLoadingRegistry($loader);
     $loader->load($registry);
 }