/**
  * set up test environment
  */
 public function setUp()
 {
     vfsStream::setup()->lastModified(50)->lastAccessed(50)->lastAttributeModified(50);
     $this->fooUrl = vfsStream::url('root/foo.txt');
     $this->barUrl = vfsStream::url('root/bar');
     $this->bazUrl = vfsStream::url('root/bar/baz.txt');
 }
Beispiel #2
0
 function setUp()
 {
     parent::setUp();
     $this->mock_cmd_runner = $this->getMock('TryLib_CommandRunner');
     $this->jenkins_runner = new TestRunner(self::JENKINS_URL, self::JENKINS_CLI, self::JENKINS_JOB, $this->mock_cmd_runner);
     vfsStream::setup('testDir');
 }
Beispiel #3
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")));
 }
Beispiel #4
0
 protected function setUpVfsStream()
 {
     if (!class_exists('vfsStream')) {
         $this->markTestSkipped('File backend tests are not available with this phpunit version.');
     }
     \vfsStream::setup('LogRoot');
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     vfsStream::setup('root');
     $this->rootDir = vfsStream::url('root');
     $this->lostAndFound = $this->rootDir . '/lost+found/';
     mkdir($this->lostAndFound);
 }
 /**
  * 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);
 }
Beispiel #7
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());
 }
 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());
 }
 public function setUp()
 {
     $this->mountDir = uniqid('mount-');
     $this->basedir = uniqid('base-');
     \vfsStream::setup($this->basedir);
     // Add an entry for the mount directory to the VFS contents
     $this->vfsContents = array($this->mountDir => array());
 }
Beispiel #10
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')));
 }
Beispiel #11
0
 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();
 }
 /**
  * @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')));
 }
 /**
  * @test
  * @since  1.4.0
  * @group  issue_68
  */
 public function unlinkNonExistingFileTriggersError()
 {
     vfsStream::setup();
     try {
         $this->assertFalse(unlink('vfs://root/foo.txt'));
     } catch (\PHPUnit_Framework_Error $fe) {
         $this->assertEquals('unlink(vfs://root/foo.txt): No such file or directory', $fe->getMessage());
     }
 }
Beispiel #14
0
 /**
  * Registers vfsStream
  *
  * @param PHPUnit_Framework_TestCase $testCase
  *
  * @return vfsStreamHelper_Wrapper
  */
 public function __construct(PHPUnit_Framework_TestCase $testCase, $mountPoint = 'root')
 {
     @(include_once 'vfsStream/vfsStream.php');
     if (!class_exists('vfsStreamWrapper')) {
         $testCase->markTestSkipped('vfsStream is not available - skipping');
     } else {
         vfsStream::setup($mountPoint);
     }
 }
 /**
  * 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'));
 }
 /**
  * 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();
 }
 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);
 }
 /**
  * @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);
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     if (defined('HPHP_VERSION')) {
         $this->markTestSkipped('Requires https://github.com/facebook/hhvm/issues/1476 to be fixed');
     }
     $this->backupIncludePath = get_include_path();
     vfsStream::setup();
     mkdir('vfs://root/a/path', 0777, true);
     set_include_path('vfs://root/a' . PATH_SEPARATOR . $this->backupIncludePath);
 }
Beispiel #20
0
 public function setUp()
 {
     // Setup VFS with base directories
     $this->ci_vfs_root = vfsStream::setup();
     $this->ci_app_root = vfsStream::newDirectory('application')->at($this->ci_vfs_root);
     $this->ci_base_root = vfsStream::newDirectory('system')->at($this->ci_vfs_root);
     $this->ci_view_root = vfsStream::newDirectory('views')->at($this->ci_app_root);
     if (method_exists($this, 'set_up')) {
         $this->set_up();
     }
 }
 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);
 }
 /**
  * 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);
 }
 protected function setUp()
 {
     $root = vfsStream::setup('root');
     $this->sourceFile = new vfsStreamFile('language_source.php');
     $this->targetFile = new vfsStreamFile('language_target.php');
     $this->targetFile->setContent(file_get_contents(__DIR__ . '/fixtures/language_merge_files_original.php'));
     $root->addChild($this->sourceFile);
     $root->addChild($this->targetFile);
     $sourceFilePath = vfsStream::url('root/language_source.php');
     $targetFilePath = vfsStream::url('root/language_target.php');
     $this->sourceFileObj = $this->getMock('Language_File', array('parse'), array($sourceFilePath));
     $this->targetFileObj = $this->getMock('Language_File', array('parse'), array($targetFilePath));
     $this->obj = new Language_MergeFiles($this->sourceFileObj, $this->targetFileObj);
 }
 protected function setUp()
 {
     $this->obj = new Language_CollectFiles();
     // setup a mock filesystem with directories and files
     $root = vfsStream::setup('root');
     $dir1 = new vfsStreamDirectory('dir1');
     $dir2 = new vfsStreamDirectory('dir2');
     $root->addChild($dir1);
     $root->addChild($dir2);
     $dir1->addChild(new vfsStreamFile('file1.tpl'));
     $dir2->addChild(new vfsStreamFile('file2.php'));
     $dir2->addChild(new vfsStreamFile('file3.php'));
     $dir2->addChild(new vfsStreamFile('file4.txt'));
 }
Beispiel #25
0
 /**
  * Tests the itterator, file contents and parsing.
  *
  * @dataProvider dataProvider
  *
  * @param array $positionalInfo
  * @param string $fileContents
  * @param array $dataExpected
  */
 public function testProcessor(array $positionalInfo, $fileContents, array $dataExpected, array $errors, $skipLines = 0)
 {
     $dir = vfsStream::setup('base');
     file_put_contents(vfsStream::url('base/test.csv'), $fileContents);
     //error_log(print_r(file_get_contents(vfsStream::url('base/test.csv')), 1));
     $params = array('location' => vfsStream::url('base/test.csv'));
     $dialect = new Dfp_Datafeed_File_Format_Ascii_Dialect_Positional();
     $dialect->setPositionalInfo($positionalInfo);
     $dialect->setSkipLines($skipLines);
     $sut = new Dfp_Datafeed_File_Reader_Format_Ascii($params);
     $sut->setDialect($dialect);
     $data = array();
     $reader = new Dfp_Datafeed_File_Reader();
     $reader->setFormat($sut);
     foreach ($reader as $record) {
         $data[] = $record;
     }
     $this->assertSame($dataExpected, $data);
     $this->assertSame($sut->getErrors(), $errors);
 }
 protected function setUp()
 {
     // setup a mock filesystem with directories and files
     $root = vfsStream::setup('root');
     $dir1 = new vfsStreamDirectory('dir1');
     $dir2 = new vfsStreamDirectory('dir2');
     $this->langDir = new vfsStreamDirectory('lang');
     $this->esDir = new vfsStreamDirectory('es');
     $file1 = new vfsStreamFile('file1.tpl');
     $file1->setContent(file_get_contents(__DIR__ . '/fixtures/test_collecting_strings.tpl'));
     $file2 = new vfsStreamFile('file2.php');
     $file2->setContent(file_get_contents(__DIR__ . '/fixtures/test_collecting_strings.php'));
     $langFile = new vfsStreamFile('language.php');
     $langFile->setContent(file_get_contents(__DIR__ . '/fixtures/language_end_to_end_test_original.php'));
     $dir1->addChild($file1);
     $dir2->addChild($file2);
     $this->langDir->addChild($this->esDir);
     $this->esDir->addChild($langFile);
     $root->addChild($dir1);
     $root->addChild($dir2);
     $root->addChild($this->langDir);
 }
 function setUp($settingFile = '')
 {
     $this->extension = $this->getMock('Tx_ExtensionBuilder_Domain_Model_Extension', array('getExtensionDir'));
     $extensionKey = 'dummy';
     //$dummyExtensionDir = PATH_typo3conf.'ext/extension_builder/Tests/Examples/'.$extensionKey.'/';
     vfsStream::setup('testDir');
     $dummyExtensionDir = vfsStream::url('testDir') . '/';
     $this->extension->setExtensionKey($extensionKey);
     $this->extension->expects($this->any())->method('getExtensionDir')->will($this->returnValue($dummyExtensionDir));
     $yamlParser = new Tx_ExtensionBuilder_Utility_SpycYAMLParser();
     $settings = $yamlParser->YAMLLoadString(file_get_contents(PATH_typo3conf . 'ext/extension_builder/Tests/Examples/Settings/settings1.yaml'));
     $this->extension->setSettings($settings);
     $configurationManager = t3lib_div::makeInstance('Tx_ExtensionBuilder_Configuration_ConfigurationManager');
     $this->classParser = t3lib_div::makeInstance('Tx_ExtensionBuilder_Utility_ClassParser');
     $this->roundTripService = $this->getMock($this->buildAccessibleProxy('Tx_ExtensionBuilder_Service_RoundTrip'), array('dummy'));
     $this->classBuilder = t3lib_div::makeInstance('Tx_ExtensionBuilder_Service_ClassBuilder');
     $this->classBuilder->injectConfigurationManager($configurationManager);
     $this->roundTripService->injectClassBuilder($this->classBuilder);
     $this->roundTripService->injectConfigurationManager($configurationManager);
     $this->templateParser = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_Core_Parser_TemplateParser'), array('dummy'));
     $this->codeGenerator = $this->getMock($this->buildAccessibleProxy('Tx_ExtensionBuilder_Service_CodeGenerator'), array('dummy'));
     if (class_exists('Tx_Extbase_Object_ObjectManager')) {
         $this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
         //parent::runBare(); causes a memory exhausted error??
         $this->codeGenerator->injectObjectManager($this->objectManager);
         $this->templateParser->injectObjectManager($this->objectManager);
     }
     $this->roundTripService->injectClassParser($this->classParser);
     $this->roundTripService->initialize($this->extension);
     $this->classBuilder->injectRoundtripService($this->roundTripService);
     $this->classBuilder->initialize($this->codeGenerator, $this->extension);
     $this->codeGenerator->injectTemplateParser($this->templateParser);
     $this->codeGenerator->injectClassBuilder($this->classBuilder);
     $this->codeGenerator->setSettings(array('codeTemplateRootPath' => PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/', 'extConf' => array('enableRoundtrip' => '1')));
     $this->codeGenerator->_set('codeTemplateRootPath', PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/');
     $this->codeGenerator->_set('enableRoundtrip', true);
     $this->codeGenerator->_set('extension', $this->extension);
 }
Beispiel #28
0
 public function setUp()
 {
     vfsStream::setup($this->basedir);
 }
Beispiel #29
0
 public function testCollectString_shouldNotConsiderEmptyCallsToTra()
 {
     $this->obj->addFileType(new Language_FileType_Php());
     $fileName = 'file1.php';
     $root = vfsStream::setup('root');
     $file = new vfsStreamFile($fileName);
     $file->setContent("'sub' => array(\n\t\t\t       'required' => false,\n\t\t\t       'default' => 'n',\n\t\t\t       'filter' => 'alpha',\n\t\t\t       'options' => array(\n\t\t\t           array('text' => tra(''), 'value' => ''),\n\t\t\t           array('text' => tra('Yes'), 'value' => 'y'),\n\t\t\t           array('text' => tra('No'), 'value' => 'n')\n\t\t\t       ),\n\t\t\t   ),");
     $root->addChild($file);
     $expectedResult = array('Yes', 'No');
     $this->assertEquals($expectedResult, $this->obj->collectStrings(vfsStream::url('root/' . $fileName)));
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     $this->root = vfsStream::setup();
 }