Esempio n. 1
0
 public function __construct()
 {
     $config = new stdClass();
     $config->paths = new stdClass();
     $config->paths->docroot = null;
     $config->site = new stdClass();
     $config->site->mode = 'prod';
     $config->site->cdnPrefix = 'a';
     $config->defaults = new stdClass();
     $config->defaults->cdnPrefix = '';
     $config->defaults->mediaVersion = 'a';
     parent::__construct(array('config' => $config));
     if (class_exists('vfsStream')) {
         vfsStreamWrapper::register();
         vfsStreamWrapper::setRoot(new vfsStreamDirectory('assetDir'));
         $config->paths->docroot = vfsStream::url('assetDir');
     }
     $this->docroot = $config->paths->docroot;
     $this->cacheDir = sprintf('%s/assets/cache', $this->docroot);
     $this->assets = $this->assetsRel = array('js' => array(), 'css' => array());
     $siteMode = $config->site->mode;
     if ($siteMode === 'prod') {
         $this->mode = self::minified;
     } else {
         $this->mode = self::combined;
     }
     $this->returnAsHeader = false;
 }
Esempio n. 2
0
 public function setUp()
 {
     if (class_exists('vfsStream')) {
         vfsStreamWrapper::register();
         vfsStreamWrapper::setRoot(new vfsStreamDirectory('scriptsDir'));
         $this->scriptsDir = vfsStream::url('scriptsDir');
         mkdir($upgradeDir = "{$this->scriptsDir}/upgrade");
         mkdir("{$this->scriptsDir}/upgrade/readme");
         mkdir("{$this->scriptsDir}/upgrade/base");
         mkdir("{$this->scriptsDir}/upgrade/db");
         mkdir("{$this->scriptsDir}/upgrade/db/mysql");
         mkdir("{$this->scriptsDir}/upgrade/fs");
         $this->assertTrue(is_dir($upgradeDir));
     }
     $this->config = new stdClass();
     $this->config->paths = new stdClass();
     $this->config->paths->configs = $this->scriptsDir;
     $this->config->defaults = new stdClass();
     $this->config->defaults->currentCodeVersion = '1.1.1';
     $this->config->defaults->lastCodeVersion = '2.2.2';
     $this->config->site = new stdClass();
     $this->config->site->lastCodeVersion = '3.3.3';
     $params = array('config' => $this->config);
     $this->upgrade = new Upgrade($params);
 }
 /**
  * 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 generateExtensionFromVersion1Configuration()
 {
     $this->configurationManager = $this->getMock($this->buildAccessibleProxy('Tx_ExtensionBuilder_Configuration_ConfigurationManager'), array('dummy'));
     $this->extensionSchemaBuilder = $this->objectManager->get('Tx_ExtensionBuilder_Service_ExtensionSchemaBuilder');
     $testExtensionDir = PATH_typo3conf . 'ext/extension_builder/Tests/Examples/TestExtensions/test_extension_v1/';
     $jsonFile = $testExtensionDir . Tx_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);
     } else {
         $this->fail('JSON file not found');
     }
     $this->extension = $this->extensionSchemaBuilder->build($extensionConfigurationJSON);
     $this->codeGenerator->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->codeGenerator->build($this->extension);
     $referenceFiles = t3lib_div::getAllFilesAndFoldersInPath(array(), $testExtensionDir);
     foreach ($referenceFiles as $referenceFile) {
         $createdFile = str_replace($testExtensionDir, $this->extension->getExtensionDir(), $referenceFile);
         if (!in_array(basename($createdFile), array('ExtensionBuilder.json'))) {
             // json file is generated by controller
             $referenceFileContent = str_replace(array('2011-08-11', '###YEAR###'), array(date('Y-m-d'), date('Y')), file_get_contents($referenceFile));
             //t3lib_div::writeFile(PATH_site.'fileadmin/'.basename($createdFile), file_get_contents($createdFile));
             $this->assertFileExists($createdFile, 'File ' . $createdFile . ' was not created!');
             $this->assertEquals(t3lib_div::trimExplode("\n", $referenceFileContent, TRUE), t3lib_div::trimExplode("\n", file_get_contents($createdFile), TRUE), 'File ' . $createdFile . ' was not equal to original file.');
         }
     }
 }
Esempio n. 4
0
 /**
  * @dataProvider writeRecordProvider
  * @param unknown_type $record
  * @param unknown_type $expected
  * @param unknown_type $escape
  */
 public function testWriteRecord($record, $expected, $escape, $lr)
 {
     $dir = vfsStream::setup('base');
     $sut = new Dfp_Datafeed_File_Writer_Format_Csv_File();
     $passed = $passed2 = false;
     try {
         $sut->writeRecord(array('test', 'testing', '2.35', '"test"'));
     } catch (Dfp_Datafeed_File_Writer_Exception $e) {
         if ($e->getMessage() == 'The file is not open') {
             $passed = True;
         }
     }
     $sut->open(vfsStream::url('base/test.csv'));
     try {
         $sut->writeRecord(array('test', 'testing', '2.35', '"test"'));
     } catch (Dfp_Datafeed_File_Writer_Exception $e) {
         if ($e->getMessage() == 'The dialect is invalid') {
             $passed2 = True;
         }
     }
     $mockDialect = $this->getMock('Dfp_Datafeed_File_Format_Csv_Dialect_Interface');
     $mockDialect->expects($this->any())->method('getQuote')->will($this->returnValue('"'));
     $mockDialect->expects($this->any())->method('getDelimiter')->will($this->returnValue(','));
     $mockDialect->expects($this->any())->method('getEscape')->will($this->returnValue($escape));
     $mockDialect->expects($this->any())->method('getLineReturn')->will($this->returnValue($lr));
     $sut->setDialect($mockDialect);
     $sut->writeRecord($record);
     $this->assertEquals($expected, file_get_contents(vfsStream::url('base/test.csv')));
     //echo "\n\n";var_dump(getcwd());
 }
Esempio n. 5
0
 /**
  * set up test environment
  */
 public function setUp()
 {
     vfsStream::setup('root');
     $this->rootDir = vfsStream::url('root');
     $this->lostAndFound = $this->rootDir . '/lost+found/';
     mkdir($this->lostAndFound);
 }
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory('exampleDir'));
     $this->Translation_File_Output = new Translation_File_Output_JavaScript(vfsStream::url('exampleDir/subdir1/subdir2/test.js'));
 }
 /**
  * @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 that the directory is created
  */
 public function testDirectoryIsCreated()
 {
     $example = new Example('id');
     $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('id'));
     $example->setDirectory(vfsStream::url('exampleDir'));
     $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('id'));
 }
Esempio n. 9
0
 /**
  * @large
  */
 public function testGenerateXml()
 {
     $syntaxFile = $this->fixtureDir . DIRECTORY_SEPARATOR . "test_grammar.ebnf";
     \vfsStream::setup("testdir");
     $this->assertEquals(Command::EBNF_OK, Command::main(array("s" => $syntaxFile, "o" => \vfsStream::url("testdir/out.xml"), "f" => "xml")));
     $this->assertEquals(file_get_contents($this->fixtureDir . DIRECTORY_SEPARATOR . "test_grammar.xml"), file_get_contents(\vfsStream::url("testdir/out.xml")));
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     $this->backupIncludePath = get_include_path();
     vfsStream::setup();
     mkdir('vfs://root/a/path', 0777, true);
     set_include_path('vfs://root/a' . PATH_SEPARATOR . $this->backupIncludePath);
 }
Esempio n. 11
0
 public function testGetTranslations_shouldReturnEmptyArray()
 {
     $root = vfsStream::setup('root');
     $root->addChild(new vfsStreamFile('language.php'));
     $obj = new Language_File(vfsStream::url('root/language.php'));
     $this->assertEquals(array(), $obj->getTranslations());
 }
 /**
  * @test
  */
 public function setLogFileSetsLogFile()
 {
     $this->setUpVfsStream();
     vfsStream::newFile($this->logFileName)->at(vfsStreamWrapper::getRoot());
     $writer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter');
     $writer->setLogFile($this->getDefaultFileName());
     $this->assertAttributeEquals($this->getDefaultFileName(), 'logFile', $writer);
 }
 /**
  * constructor
  *
  * @param  vfsStreamContent[]  $children
  */
 public function __construct(array $children)
 {
     $this->children = $children;
     if (vfsStream::useDotfiles()) {
         array_unshift($this->children, new DotDirectory('.'), new DotDirectory('..'));
     }
     reset($this->children);
 }
Esempio n. 14
0
 /**
  * constructor
  *
  * @param  string  $name
  * @param  int     $permissions
  */
 public function __construct($name, $permissions = 0777)
 {
     $this->name = $name;
     $this->lastModified = time();
     $this->permissions = $permissions;
     $this->user = vfsStream::getCurrentUser();
     $this->group = vfsStream::getCurrentGroup();
 }
Esempio n. 15
0
 /**
  * @test
  */
 public function getLanguagesScansFormatDirectoryAndReturnsLanguagesAsStrings()
 {
     $formatPath = \vfsStream::url('testDirectory') . '/';
     \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively($formatPath . 'en');
     $format = new \TYPO3\FLOW3\Package\Documentation\Format('DocBook', $formatPath);
     $availableLanguages = $format->getAvailableLanguages();
     $this->assertEquals(array('en'), $availableLanguages);
 }
 /**
  * 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'));
 }
Esempio n. 17
0
 function testScriptExistsAndFails()
 {
     vfsStream::newFile('script')->at(vfsStreamWrapper::getRoot());
     $script_runner = new TryLib_Precheck_ScriptRunner(vfsStream::url('testDir/script'));
     $this->mock_cmd_runner->expects($this->once())->method('run')->with('vfs://testDir/script', false, true)->will($this->returnValue(255));
     $this->mock_cmd_runner->expects($this->once())->method('terminate')->with('Failed running pre-check script vfs://testDir/script');
     $script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/master');
 }
 /**
  * @return  array
  */
 public function provideSwitchWithExpectations()
 {
     return array(array(function () {
         vfsStream::disableDotfiles();
     }, array()), array(function () {
         vfsStream::enableDotfiles();
     }, array('.', '..')));
 }
Esempio n. 19
0
 public function testScanDir_shouldAcceptIncludedFiles()
 {
     $obj = $this->getMock('Language_CollectFiles', array('getExcludeDirs', 'getIncludeFiles'));
     $obj->expects($this->exactly(3))->method('getExcludeDirs')->will($this->returnValue(array('vfs://root/dir2')));
     $obj->expects($this->exactly(2))->method('getIncludeFiles')->will($this->returnValue(array('vfs://root/dir2/file3.php')));
     $expectedResult = array('vfs://root/dir1/file1.tpl', 'vfs://root/dir2/file3.php');
     $this->assertEquals($expectedResult, $obj->scanDir(vfsStream::url('root')));
 }
Esempio n. 20
0
 /**
  * Initialize virtual filesystem
  *
  * @param string $directoryName The root of the vfs
  * @return string The created vfs' root
  */
 protected function _getVirtualFsRoot($directoryName)
 {
     //prepare vfs
     //setup vfsSW, root directory
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory($directoryName));
     return vfsStream::url($directoryName);
 }
Esempio n. 21
0
 /**
  * @test
  * @group  issue_51
  */
 public function canNotRemoveWritableFileFromNonWritableDirectory()
 {
     $structure = array('test_directory' => array('test.file' => ''));
     $root = vfsStream::setup('root', null, $structure);
     $root->getChild('test_directory')->chmod(0444);
     $root->getChild('test_directory')->getChild('test.file')->chmod(0777);
     $this->assertFalse(@unlink(vfsStream::url('root/test_directory/test.file')));
 }
Esempio n. 22
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');
 }
Esempio n. 23
0
 /**
  * @dataProvider analyzeXdebugtrace_dp
  */
 public function testAnalyzeXdebugTrace($file_content, $expected)
 {
     $f = new vfsStreamFile('file.php', 0664);
     $f->withContent($file_content);
     $this->fs->addChild($f);
     $out = $this->fa->analyzeXdebugTrace(vfsStream::url('file.php'));
     $this->assertEquals($expected, $out);
 }
 /**
  * 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'));
 }
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     vfsStream::setup('exampleDir');
     $file = vfsStream::newFile('test1.php');
     vfsStreamWrapper::getRoot()->addChild($file);
     $file->setContent('__' . '("test1"); __' . '(\'test2\')');
     $this->Translation_File_Source = new Translation_File_Source(vfsStream::url('exampleDir/test1.php'));
 }
Esempio n. 26
0
 /**
  * @test
  */
 public function vfsStreamCanHandleUrlEncodedPath()
 {
     $content = '<xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
                                 <xs:complexType name="myType"></xs:complexType>
                             </xs:schema>';
     $structure = array('foo bar' => array('schema.xsd' => $content));
     vfsStream::setup('root', null, $structure);
     $this->assertEquals($content, file_get_contents(vfsStream::url('root/foo bar/schema.xsd')));
 }
Esempio n. 27
0
 /**
  * @test
  */
 public function getDocumentationFormatsScansDocumentationDirectoryAndReturnsDocumentationFormatObjectsIndexedByFormatName()
 {
     $documentationPath = \vfsStream::url('testDirectory') . '/';
     $mockPackage = $this->getMock('TYPO3\\FLOW3\\Package\\PackageInterface');
     \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively($documentationPath . 'DocBook/en');
     $documentation = new \TYPO3\FLOW3\Package\Documentation($mockPackage, 'Manual', $documentationPath);
     $documentationFormats = $documentation->getDocumentationFormats();
     $this->assertEquals('DocBook', $documentationFormats['DocBook']->getFormatName());
 }
 /**
  * @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());
 }
 /**
  * @test
  */
 public function flockSouldPass()
 {
     $fp = fopen(vfsStream::url('root/testfile'), 'w');
     flock($fp, LOCK_EX);
     fwrite($fp, "another string\n");
     flock($fp, LOCK_UN);
     fclose($fp);
     $this->assertEquals("another string\n", file_get_contents(vfsStream::url('root/testfile')));
 }
Esempio n. 30
0
 public function testMerge_shouldUpdateTargetFileWithTranslationsFromSourceFile()
 {
     $sourceFileData = array('Bytecode Cache' => array('key' => 'Bytecode Cache', 'translated' => false), 'Used' => array('key' => 'Used', 'translation' => "Usado", 'translated' => true), 'Available' => array('key' => 'Available', 'translation' => 'Disponível', 'translated' => true), 'Memory' => array('key' => 'Memory', 'translation' => 'Memória', 'translated' => true), '%0 enabled' => array('key' => '%0 enabled', 'translation' => '%0 habilitado', 'translated' => true), 'Features' => array('key' => 'Features', 'translation' => 'Recursos', 'translated' => true), 'Wiki Config' => array('key' => 'Wiki Config', 'translations' => 'Configuração Wiki', 'translated' => true));
     $targetFileData = array('Bytecode Cache' => array('key' => 'Bytecode Cache', 'translated' => false), 'Used' => array('key' => 'Used', 'translation' => "Usado", 'translated' => true), 'Available' => array('key' => 'Available', 'translated' => false), 'Memory' => array('key' => 'Memory', 'translated' => false), '%0 enabled' => array('key' => '%0 enabled', 'translation' => '%0 habilitado', 'translated' => true), 'Features' => array('key' => 'Features', 'translation' => 'Recursos antigos', 'translated' => true), 'Tiki Admin' => array('key' => 'Tiki Admin', 'translation' => 'Administração do Tiki', 'translated' => true));
     $this->sourceFileObj->expects($this->once())->method('parse')->will($this->returnValue($sourceFileData));
     $this->targetFileObj->expects($this->once())->method('parse')->will($this->returnValue($targetFileData));
     $this->obj->merge();
     $this->assertEquals(file_get_contents(__DIR__ . '/fixtures/language_merge_files_result.php'), file_get_contents(vfsStream::url('root/language_target.php')));
 }