コード例 #1
0
ファイル: FileTest.php プロジェクト: henryhayes/dfp
 /**
  * @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());
 }
コード例 #2
0
ファイル: SATest.php プロジェクト: noseglid/phpa
 public function testExtractSourceBadFileException()
 {
     vfsStreamWrapper::getRoot()->addChild(vfsStream::newFile('unreadable', 00));
     $unit = array('file' => vfsStream::url('unreadable'), 'row' => '10');
     $this->setExpectedException('Exception');
     $this->sa->extractSource($unit);
 }
コード例 #3
0
 /**
  * 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'));
 }
コード例 #4
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());
 }
コード例 #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);
 }
 /**
  * @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']));
         }
     }
 }
コード例 #7
0
 /**
  * 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'));
 }
コード例 #8
0
 /**
  * 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.');
         }
     }
 }
コード例 #9
0
ファイル: CommandTest.php プロジェクト: bgarrels/ebnf
 /**
  * @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")));
 }
コード例 #10
0
ファイル: UpgradeTest.php プロジェクト: nicolargo/frontend
 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);
 }
コード例 #11
0
ファイル: AssetPipelineTest.php プロジェクト: gg1977/frontend
 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;
 }
コード例 #12
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')));
 }
コード例 #13
0
ファイル: FormatTest.php プロジェクト: nxpthx/FLOW3
 /**
  * @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);
 }
コード例 #14
0
ファイル: ScriptRunnerTest.php プロジェクト: seanly/TryLib
 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');
 }
コード例 #15
0
ファイル: PageFileMapperTest.php プロジェクト: erenon/Light
 /**
  * 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);
 }
コード例 #16
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')));
 }
コード例 #17
0
ファイル: FATest.php プロジェクト: noseglid/phpa
 /**
  * @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);
 }
コード例 #18
0
ファイル: NTLMTest.php プロジェクト: caseypage/php-ssrs
 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');
 }
コード例 #19
0
 /**
  * @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());
 }
コード例 #20
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')));
 }
コード例 #21
0
ファイル: DocumentationTest.php プロジェクト: nxpthx/FLOW3
 /**
  * @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());
 }
コード例 #22
0
ファイル: FactoryTest.php プロジェクト: hurcane/tiki-azure
 protected function setUp()
 {
     // setup a mock filesystem
     $lang = vfsStream::setup('lang');
     $this->langFile = new vfsStreamFile('language.php');
     $lang->addChild($this->langFile);
     $this->filePath = vfsStream::url('lang/language.php');
     $this->obj = new Language_WriteFile_Factory();
 }
コード例 #23
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')));
 }
コード例 #24
0
 /**
  * @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')));
 }
コード例 #25
0
 /**
  * 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'));
 }
コード例 #26
0
 /**
  * @test
  * @expectedException \PHPUnit_Framework_Error
  */
 public function selectStream()
 {
     $root = vfsStream::setup();
     $file = vfsStream::newFile('foo.txt')->at($root)->withContent('testContent');
     $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
     $readarray = array($fp);
     $writearray = array();
     $exceptarray = array();
     stream_select($readarray, $writearray, $exceptarray, 1);
 }
コード例 #27
0
 protected function setUp()
 {
     // setup a mock filesystem
     $lang = vfsStream::setup('lang');
     $this->langFile = new vfsStreamFile('language.php');
     $lang->addChild($this->langFile);
     $this->parseFile = $this->getMock('Language_File', array('getTranslations'), array(vfsStream::url('lang/language.php')));
     $this->filePath = vfsStream::url('lang/language.php');
     $this->obj = new Language_WriteFile($this->parseFile);
 }
コード例 #28
0
 /**
  * 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);
 }
コード例 #29
0
ファイル: UATest.php プロジェクト: noseglid/phpa
 /**
  * @dataProvider analyze_dp
  */
 function testAnalyze($data, $file_content, $expected)
 {
     foreach ($data['files'] as $k => $file) {
         $f = new vfsStreamFile($file, 0664);
         $f->withContent($file_content[$k]);
         $this->fsroot->addChild($f);
         $data['files'][$k] = vfsStream::url($data['files'][$k]);
     }
     $this->ua->analyze($data);
     $this->assertEquals($expected, $data);
 }
コード例 #30
0
 /**
  * @test
  * @author Christopher Hlubek <*****@*****.**>
  */
 public function saveWritesDoesNotOverwriteExistingHeaderCommentsIfFileExists()
 {
     $pathAndFilename = \vfsStream::url('testDirectory') . '/YAMLConfiguration';
     $comment = '# This comment should stay' . chr(10) . 'Test: foo' . chr(10);
     file_put_contents($pathAndFilename . '.yaml', $comment);
     $configurationSource = new \F3\FLOW3\Configuration\Source\YamlSource();
     $configurationSource->save($pathAndFilename, array('configurationFileHasBeenLoaded' => TRUE));
     $yaml = file_get_contents($pathAndFilename . '.yaml');
     $this->assertContains('# This comment should stay', $yaml, 'Header comment was removed from file.');
     $this->assertNotContains('Test: foo', $yaml);
 }