public function testGetStrings_endToEnd_severalLanguageFiles()
 {
     $ruDir = new vfsStreamDirectory('ru');
     $faDir = new vfsStreamDirectory('fa');
     $ruFile = new vfsStreamFile('language.php');
     $ruFile->setContent(file_get_contents(__DIR__ . '/fixtures/language_ru_original.php'));
     $ruDir->addChild($ruFile);
     $faFile = new vfsStreamFile('language.php');
     $faFile->setContent(file_get_contents(__DIR__ . '/fixtures/language_fa_original.php'));
     $faDir->addChild($faFile);
     $this->langDir->addChild($ruDir);
     $this->langDir->addChild($faDir);
     $obj = new Language_GetStrings(new Language_CollectFiles(), new Language_WriteFile_Factory(), array('baseDir' => vfsStream::url('root')));
     $obj->addFileType(new Language_FileType_Php());
     $obj->addFileType(new Language_FileType_Tpl());
     $obj->run();
     $this->assertEquals(file_get_contents(__DIR__ . '/fixtures/language_ru_modified.php'), file_get_contents(vfsStream::url('root/lang/ru/language.php')));
     $this->assertEquals(file_get_contents(__DIR__ . '/fixtures/language_fa_modified.php'), file_get_contents(vfsStream::url('root/lang/fa/language.php')));
 }
Beispiel #2
0
        // when a custom base dir is set, default $includeFiles and $excludeDirs are not used
        $includeFiles = array();
        $excludeDirs = array();
    }
    if ($request->hasProperty('excludeDirs')) {
        $excludeDirs = explode(',', $request->getProperty('excludeDirs'));
    }
    if ($request->hasProperty('includeFiles')) {
        $includeFiles = explode(',', $request->getProperty('includeFiles'));
    }
    if ($request->hasProperty('fileName')) {
        $options['fileName'] = $request->getProperty('fileName');
    }
}
$getStrings = new Language_GetStrings(new Language_CollectFiles(), new Language_WriteFile_Factory(), $options);
$getStrings->addFileType(new Language_FileType_Php());
$getStrings->addFileType(new Language_FileType_Tpl());
// skip the following directories
$getStrings->collectFiles->setExcludeDirs($excludeDirs);
// manually add the following files from skipped directories
$getStrings->collectFiles->setIncludeFiles($includeFiles);
echo formatOutput("Languages: " . implode(' ', $getStrings->getLanguages()) . "\n");
$getStrings->run();
echo formatOutput("\nTotal time spent: " . $timer->stop() . " seconds\n");
/**
 * @param $string
 * @return string
 */
function formatOutput($string)
{
    if (php_sapi_name() == 'cli') {