/**
  * @param ilTermsOfServiceAgreementByLanguageProvider $provider
  * @depends testAgreementByLanguageProviderCanBeCreatedByFactory
  */
 public function testProviderReturnsAResultForEveryInstalledLanguage(ilTermsOfServiceAgreementByLanguageProvider $provider)
 {
     $client_rel_path = implode('/', array('clients', 'default', 'agreement'));
     $global_rel_path = implode('/', array('global', 'agreement'));
     $root = vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
     $customizing_dir = vfsStream::newDirectory('Customizing')->at($root);
     $client_dir = vfsStream::newDirectory($client_rel_path)->at($customizing_dir);
     vfsStream::newFile('agreement_de.html', 0777)->at($client_dir);
     file_put_contents(vfsStream::url('root/Customizing/' . $client_rel_path . '/agreement_de.html'), 'phpunit');
     $global_dir = vfsStream::newDirectory($global_rel_path)->at($customizing_dir);
     vfsStream::newFile('agreement_en.html', 0777)->at($global_dir);
     file_put_contents(vfsStream::url('root/Customizing/' . $global_rel_path . '/agreement_en.html'), 'phpunit');
     $provider->setSourceDirectories(array(vfsStream::url('root/Customizing/' . $client_rel_path), vfsStream::url('root/Customizing/' . $global_rel_path)));
     $lng = $this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->getMock();
     $installed_languages = array('en', 'de', 'fr');
     $lng->expects($this->once())->method('getInstalledLanguages')->will($this->onConsecutiveCalls($installed_languages));
     $provider->setLanguageAdapter($lng);
     $data = $provider->getList(array(), array());
     $this->assertArrayHasKey('items', $data);
     $this->assertArrayHasKey('cnt', $data);
     $this->assertCount(count($installed_languages), $data['items']);
     $this->assertEquals(count($installed_languages), $data['cnt']);
     for ($i = 0; $i < count($installed_languages); $i++) {
         $this->assertArrayHasKey('language', $data['items'][$i]);
         $this->assertArrayHasKey('agreement', $data['items'][$i]);
         $this->assertArrayHasKey('agreement_document', $data['items'][$i]);
         $this->assertArrayHasKey('agreement_document_modification_ts', $data['items'][$i]);
         if ($installed_languages[$i] == 'fr') {
             $this->assertFalse(file_exists($data['items'][$i]['agreement_document']));
         } else {
             $this->assertTrue(file_exists($data['items'][$i]['agreement_document']));
         }
     }
 }
 /**
  * Test: should rename directory name as string internal
  *
  * @small
  */
 public function testShouldRenameDirectoryNameAsStringInternal()
 {
     $dir = $this->rootDirectory->getChild('var/log/app');
     $dir->addChild(vfsStream::newDirectory(80));
     $child = $this->rootDirectory->getChild('var/log/app/80');
     $child->rename(90);
     static::assertNotNull($this->rootDirectory->getChild('var/log/app/90'));
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     if (extension_loaded('zip') === false) {
         $this->markTestSkipped('No ext/zip installed, skipping test.');
     }
     $this->markTestSkipped('Zip extension can not work with vfsStream urls.');
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
 }
 /**
  * Setup
  */
 protected function setUp()
 {
     if ($this->isVsfStreamInstalled()) {
         vfsStream::setup();
         $this->setTestDirectory(vfsStream::newDirectory('tests')->at(vfsStreamWrapper::getRoot()));
         define('CLIENT_DATA_DIR', vfsStream::url('root/tests'));
     }
     parent::setUp();
 }
 /**
  * @test
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function specialClassNamesAndPathsSettingsOverrideClassLoaderBehaviour()
 {
     $root = \vfsStream::newDirectory('Packages/Virtual/Resources/PHP');
     \vfsStreamWrapper::setRoot($root);
     $vfsClassFile = \vfsStream::newFile('Bar.php')->withContent('<?php ?>')->at($root->getChild('Virtual/Resources/PHP'));
     $this->classLoader->setSpecialClassNameAndPath('Baz', \vfsStream::url('Virtual/Resources/PHP/Bar.php'));
     $this->classLoader->loadClass('Baz');
     $this->assertTrue($vfsClassFile->eof());
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     $this->rootDirectory = vfsStream::newDirectory('/');
     $this->rootDirectory->addChild(vfsStream::newDirectory('var/log/app'));
     $dir = $this->rootDirectory->getChild('var/log/app');
     $dir->addChild(vfsStream::newDirectory('app1'));
     $dir->addChild(vfsStream::newDirectory('app2'));
     $dir->addChild(vfsStream::newDirectory('foo'));
 }
 /**
  * it should look for pantrfile in parent directories
  * @author Patrick Gotthardt
  * @test
  */
 public function it_should_look_for_taskfile_in_parent_directories()
 {
     $file = vfsStream::url('r/pantrfile.php');
     file_put_contents($file, 'test');
     $basedir = 'r/foo/bar/baz';
     $dir = vfsStream::newDirectory($basedir);
     $fac = new CyclicResolutionTaskFileFactory(vfsStream::url($basedir));
     $pfile = $fac->getTaskFile('pantrfile');
     $this->assertNotNull($pfile);
 }
示例#8
0
 public function setUp()
 {
     if (class_exists('vfsStream', false) === false) {
         $this->markTestSkipped('vfsStream not installed.');
     }
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('home/test');
     $root->getChild('test')->addChild(vfsStream::newFile('succeed.php'));
     $root->getChild('test')->addChild(vfsStream::newFile('succeed2.php'));
     $root->getChild('test')->addChild(vfsStream::newFile('succeed3.php'));
     vfsStreamWrapper::setRoot($root);
 }
 /**
  * helper method for setting up vfsStream with the proxy
  *
  * @param   string              $rootDirName  optional  name of root directory
  * @param   int                 $permissions  optional  file permissions of root directory
  * @return  vfsStreamDirectory
  * @throws  vfsStreamException
  */
 public static function setup($rootDirName = 'root', $permissions = null)
 {
     self::$root = vfsStream::newDirectory($rootDirName, $permissions);
     if (true === self::$registered) {
         return self::$root;
     }
     if (@stream_wrapper_register(vfsStream::SCHEME, __CLASS__) === false) {
         throw new vfsStreamException('A handler has already been registered for the ' . vfsStream::SCHEME . ' protocol.');
     }
     self::$registered = true;
     return self::$root;
 }
 protected function setUp()
 {
     $root = vfsStream::setup('PasswordLibTest');
     //Setup Folders
     $core = vfsStream::newDirectory('Core')->at($root);
     $af = vfsStream::newDirectory('AbstractFactory')->at($core);
     // Create Files
     vfsStream::newFile('test.php')->at($af);
     vfsStream::newFile('Some234Foo234Bar98Name.php')->at($af);
     vfsStream::newFile('Invalid.csv')->at($af);
     vfsStream::newFile('badlocation.php')->at($core);
 }
 /**
  *
  */
 public function setUp()
 {
     vfsStreamWrapper::register();
     $root = vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
     $customizing_dir = vfsStream::newDirectory('Customizing')->at($root);
     $this->client_dir = vfsStream::newDirectory('clients/default/agreement')->at($customizing_dir);
     $this->global_dir = vfsStream::newDirectory('global/agreement')->at($customizing_dir);
     $this->lng = $this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->getMock();
     $this->lng->expects($this->any())->method('getLangKey')->will($this->returnValue('de'));
     $this->lng->expects($this->any())->method('getDefaultLanguage')->will($this->returnValue('fr'));
     $this->source_files = array(vfsStream::url(implode('/', array('root', 'Customizing', 'clients', 'default', 'agreement', 'agreement_' . $this->lng->getLangKey() . '.html'))) => $this->lng->getLangKey(), vfsStream::url(implode('/', array('root', 'Customizing', 'clients', 'default', 'agreement', 'agreement_' . $this->lng->getDefaultLanguage() . '.html'))) => $this->lng->getDefaultLanguage(), vfsStream::url(implode('/', array('root', 'Customizing', 'clients', 'default', 'agreement', 'agreement_en.html'))) => 'en', vfsStream::url(implode('/', array('root', 'Customizing', 'global', 'agreement', 'agreement_' . $this->lng->getLangKey() . '.html'))) => $this->lng->getLangKey(), vfsStream::url(implode('/', array('root', 'Customizing', 'global', 'agreement', 'agreement_' . $this->lng->getDefaultLanguage() . '.html'))) => $this->lng->getDefaultLanguage(), vfsStream::url(implode('/', array('root', 'Customizing', 'global', 'agreement', 'agreement_en.html'))) => 'en');
 }
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     vfsStream::setup('exampleDir');
     $dir = vfsStream::newDirectory('subDir1');
     vfsStreamWrapper::getRoot()->addChild($dir);
     vfsStreamWrapper::getRoot()->addChild(vfsStream::newFile('test1.php'));
     $dir->addChild(vfsStream::newFile('test2.php'));
     $dir->addChild(vfsStream::newFile('test3.js'));
     $dir->addChild(vfsStream::newFile('test4.xml'));
     $extentions = array('php' => array('PHP'));
     $this->Translation_Collector_Source_Files = new Translation_Collector_Source_Files(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(vfsStream::url('exampleDir'))), $extentions);
 }
示例#13
0
 /**
  * Since we use paths to load up models, views, etc, we need the ability to
  * mock up the file system so when core tests are run, we aren't mucking
  * in the application directory.  this will give finer grained control over
  * these tests.  So yeah, while this looks odd, I need to overwrite protected
  * class vars in the loader.  So here we go...
  *
  * @covers CI_Loader::__construct()
  */
 public function __construct()
 {
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory('application'));
     $this->models_dir = vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot());
     $this->libs_dir = vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot());
     $this->helpers_dir = vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot());
     $this->views_dir = vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot());
     $this->_ci_ob_level = ob_get_level();
     $this->_ci_library_paths = array(vfsStream::url('application') . '/', BASEPATH);
     $this->_ci_helper_paths = array(vfsStream::url('application') . '/', BASEPATH);
     $this->_ci_model_paths = array(vfsStream::url('application') . '/');
     $this->_ci_view_paths = array(vfsStream::url('application') . '/views/' => TRUE);
 }
示例#14
0
 public function setUp()
 {
     if (class_exists('vfsStream', false) === false) {
         $this->markTestSkipped('vfsStream not installed.');
     }
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('home/config');
     $root->getChild('config')->addChild(vfsStream::newFile('crypto.php')->withContent('
         <?php $config_auth["keyphrase"] = "moo"; $config_auth["base_salt"] = "baa"; ?>
     '));
     vfsStreamWrapper::setRoot($root);
     self::$slc = $this->getMock('\\Core\\Session\\LocalStorage', array('get', 'set', 'destroy'));
     self::$srp = $this->getMock('\\Core\\Session\\RemoteStorage', array('set_remote_addr', '__set', '__get', 'save', 'add', 'load', 'destroy'));
     self::$sh = new \Core\Session\Handler();
     self::$sh->set_remote_addr(TEST_IP)->attach_local_storage(self::$slc)->attach_remote_storage(self::$srp)->initialize_remote_storage()->attach_crypto_config('vfs://config/crypto.php');
 }
示例#15
0
 /**
  * @test
  * @group  issue_4
  * @since  0.11.0
  */
 public function copyFromWithSubFolders()
 {
     $baseDir = vfsStream::copyFromFileSystem($this->getFileSystemCopyDir(), vfsStream::newDirectory('test'), 3);
     $this->assertTrue($baseDir->hasChildren());
     $this->assertTrue($baseDir->hasChild('emptyFolder'));
     $this->assertTrue($baseDir->hasChild('withSubfolders'));
     $subfolderDir = $baseDir->getChild('withSubfolders');
     $this->assertTrue($subfolderDir->hasChild('subfolder1'));
     $this->assertTrue($subfolderDir->getChild('subfolder1')->hasChild('file1.txt'));
     $this->assertVfsFile($subfolderDir->getChild('subfolder1/file1.txt'), '');
     $this->assertTrue($subfolderDir->hasChild('subfolder2'));
     $this->assertTrue($subfolderDir->hasChild('aFile.txt'));
     $this->assertVfsFile($subfolderDir->getChild('aFile.txt'), 'foo');
 }
示例#16
0
 /**
  * Creates virtual directories using vfsStream plugin
  *
  * @see phpucAbstractTest::setUpVfsStream()
  *
  * @param array $directories List of directories
  *
  * @return void
  */
 protected function createVfsDirectories(array $directories)
 {
     foreach ($directories as $directory) {
         vfsStream::newDirectory($directory)->at(vfsStreamWrapper::getRoot());
     }
 }
示例#17
0
 /**
  * Create VFS directory
  *
  * @param	string	Directory name
  * @param	object	Optional root to create in
  * @return	object	New directory object
  */
 public function ci_vfs_mkdir($name, $root = NULL)
 {
     // Check for root
     if (!$root) {
         $root = $this->ci_vfs_root;
     }
     // Return new directory object
     return vfsStream::newDirectory($name)->at($root);
 }
示例#18
0
 /**
  * @test
  * @group  issue_121
  * @since  1.6.1
  */
 public function createDirectoryWithTrailingSlashShouldNotCreateSubdirectoryWithEmptyName()
 {
     $directory = vfsStream::newDirectory('foo/');
     $this->assertFalse($directory->hasChildren());
 }
示例#19
0
 /**
  * set up test environmemt
  */
 public function setUp()
 {
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(vfsStream::newDirectory('exampleDir'));
 }
 /**
  * @test
  * @since  0.11.0
  */
 public function setRootReturnsRoot()
 {
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('root');
     $this->assertSame($root, vfsStreamWrapper::setRoot($root));
 }
 /**
  * @test
  * @since  0.11.0
  * @group  issue_23
  */
 public function unlinkCanNotRemoveEmptyDirectory()
 {
     vfsStream::newDirectory('empty')->at($this->foo);
     try {
         $this->assertTrue(unlink($this->fooURL . '/empty'));
     } catch (\PHPUnit_Framework_Error $fe) {
         $this->assertEquals('unlink(vfs://foo/empty): Operation not permitted', $fe->getMessage());
     }
     $this->assertTrue($this->foo->hasChild('empty'));
     $this->assertFileExists($this->fooURL . '/empty');
 }
示例#22
0
 /**
  * @covers vfsStreamHelper_Directory::__construct
  * @covers vfsStreamHelper_Directory::getName
  * @covers vfsStreamHelper_Directory::getRoot
  */
 public function testNewDirWithRoot()
 {
     $newDir = 'secondDir';
     $parentDir = 'firstDir';
     $root = vfsStream::newDirectory($parentDir)->at(vfsStreamWrapper::getRoot());
     $directory = new vfsStreamHelper_Directory($newDir, $parentDir);
     $this->assertType('vfsStreamDirectory', $root);
     $this->assertAttributeEquals($newDir, '_name', $directory);
     $this->assertAttributeEquals($root, '_root', $directory);
     $this->assertEquals($newDir, $directory->getName());
     $this->assertEquals($root, $directory->getRoot());
 }
 /**
  * @test
  * @group  issue_7
  */
 public function renameFileDoesNotChangeFileTimesOfFileItself()
 {
     $target = vfsStream::newDirectory('target')->at(vfsStreamWrapper::getRoot())->lastModified(200)->lastAccessed(200)->lastAttributeModified(200);
     $source = vfsStream::newDirectory('bar')->at(vfsStreamWrapper::getRoot());
     $file = vfsStream::newFile('baz.txt')->at($source)->lastModified(300)->lastAccessed(300)->lastAttributeModified(300);
     $source->lastModified(100)->lastAccessed(100)->lastAttributeModified(100);
     rename($this->bazUrl, vfsStream::url('root/target/baz.txt'));
     $this->assertEquals(300, filemtime(vfsStream::url('root/target/baz.txt')));
     $this->assertEquals(300, filectime(vfsStream::url('root/target/baz.txt')));
     $this->assertEquals(300, fileatime(vfsStream::url('root/target/baz.txt')));
     $this->assertFileTimesEqualStreamTimes(vfsStream::url('root/target/baz.txt'), $file);
 }
示例#24
0
 /**
  * creates a new directory
  *
  * @param   string  $path
  * @param   int     $mode
  * @param   int     $options
  * @return  bool
  */
 public function mkdir($path, $mode, $options)
 {
     $umask = vfsStream::umask();
     if (0 < $umask) {
         $permissions = $mode & ~$umask;
     } else {
         $permissions = $mode;
     }
     $path = $this->resolvePath(vfsStream::path($path));
     if (null !== $this->getContent($path)) {
         trigger_error('mkdir(): Path vfs://' . $path . ' exists', E_USER_WARNING);
         return false;
     }
     if (null === self::$root) {
         self::$root = vfsStream::newDirectory($path, $permissions);
         return true;
     }
     $maxDepth = count(explode('/', $path));
     $names = $this->splitPath($path);
     $newDirs = $names['basename'];
     $dir = null;
     $i = 0;
     while ($dir === null && $i < $maxDepth) {
         $dir = $this->getContent($names['dirname']);
         $names = $this->splitPath($names['dirname']);
         if (null == $dir) {
             $newDirs = $names['basename'] . '/' . $newDirs;
         }
         $i++;
     }
     if (null === $dir || $dir->getType() !== vfsStreamContent::TYPE_DIR || $dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
         return false;
     }
     $recursive = (STREAM_MKDIR_RECURSIVE & $options) !== 0 ? true : false;
     if (strpos($newDirs, '/') !== false && false === $recursive) {
         return false;
     }
     vfsStream::newDirectory($newDirs, $permissions)->at($dir);
     return true;
 }
 /**
  * @test
  * @group  issue_33
  */
 public function canNotTruncateToGreaterLengthWhenDiscQuotaReached()
 {
     if (version_compare(PHP_VERSION, '5.4.0', '<')) {
         $this->markTestSkipped('Requires PHP 5.4');
     }
     vfsStream::newFile('bar.txt')->withContent('1234567890')->at(vfsStream::newDirectory('bar')->at($this->root));
     $fp = fopen(vfsStream::url('root/file.txt'), 'w+');
     $this->assertFalse(ftruncate($fp, 11));
     fclose($fp);
     $this->assertEquals(0, $this->root->getChild('file.txt')->size());
     $this->assertEquals('', $this->root->getChild('file.txt')->getContent());
 }
示例#26
0
 /**
  * creates a new directory
  *
  * @param   string  $path
  * @param   int     $mode
  * @param   int     $options
  * @return  bool
  */
 public function mkdir($path, $mode, $options)
 {
     $mode = null == $mode ? 0777 : $mode;
     $path = vfsStream::path($path);
     if (null === self::$root) {
         self::$root = vfsStream::newDirectory($path, $mode);
         return true;
     }
     $maxDepth = count(explode('/', $path));
     $names = $this->splitPath($path);
     $newDirs = $names['basename'];
     $dir = null;
     $i = 0;
     while ($dir === null && $i < $maxDepth) {
         $dir = $this->getContent($names['dirname']);
         $names = $this->splitPath($names['dirname']);
         $newDirs = $names['basename'] . '/' . $newDirs;
         $i++;
     }
     if (null === $dir || $dir->getType() !== vfsStreamContent::TYPE_DIR) {
         return false;
     }
     $newDirs = str_replace($dir->getName() . '/', '', $newDirs);
     $recursive = (STREAM_MKDIR_RECURSIVE & $options) !== 0 ? true : false;
     if (strpos($newDirs, '/') !== false && false === $recursive) {
         return false;
     }
     vfsStream::newDirectory($newDirs, $mode)->at($dir);
     return true;
 }
示例#27
0
 /**
  * Creates a virtual directory
  *
  * @param vfsStreamHelper_Directory $directory
  *
  * @return vfsStreamDirectory
  */
 protected function createDirectoryFromObject(vfsStreamHelper_Directory $directory)
 {
     return vfsStream::newDirectory($directory->getName())->at($directory->getRoot());
 }