Ejemplo n.º 1
0
 /**
  * Clean all sugar language files.
  */
 public function clean($sort = true, $test = false)
 {
     $finder = new Finder();
     $finder->files()->in($this->getApplication()->getPath())->path('/^custom\\/include\\/language/')->depth('== 3')->name('*.lang.php');
     $found_one = false;
     foreach ($finder as $file) {
         $this->getLogger()->notice('Processing file ' . $file);
         $found_one = true;
         $content = file_get_contents($file);
         if ($content === false) {
             throw new \Exception('Unable to load the file contents of ' . $file . '.');
         }
         $lang = new LangFile($this->getLogger(), $content, $test);
         file_put_contents($file, $lang->getSortedFile($sort));
     }
     if (!$found_one) {
         $this->getLogger()->notice('No lang files found to process.');
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
    public function testCheckVarName()
    {
        $local = '$foo';
        $global = "\$GLOBALS['foo']";
        $logger = new TestLogger();
        $lang = new LangFile($logger, '', false);
        $this->assertNull($lang->checkVarName(''));
        $lang->var_blocks[$local] = '';
        $lang->checkVarName($local);
        $lang->checkVarName($global);
        $lang->var_blocks = array($global => '');
        $lang->checkVarName($local);
        $log = <<<'EOF'
[warning] Found duplicate definition for $foo.

EOF;
        $this->assertEquals($log, $logger->getLines());
    }