public function testGetStats_shouldReturnEmptyStats() { $expectedResult = array('total' => 0, 'translated' => 0, 'untranslated' => 0, 'percentage' => 0); $root = vfsStream::setup('root'); $file = new vfsStreamFile('language.php'); $root->addChild($file); $obj = new Language_File(vfsStream::url('root/language.php')); $this->assertEquals($expectedResult, $obj->getStats()); }
// update all language.php files by calling get_strings.php $output = array(); $return_var = null; exec('php get_strings.php', $output, $return_var); if ($return_var == 1) { die("\nCouln't execute get_strings.php\n\n"); } // calculate the percentage for each language.php $outputData = array(); $globalStats = array(); // $langmapping is set on lang/langmapping.php foreach ($langmapping as $lang => $null) { $filePath = "lang/{$lang}/language.php"; if (file_exists($filePath) && $lang != 'en') { $parseFile = new Language_File($filePath); $stats = $parseFile->getStats(); $outputData[$lang] = array('total' => $stats['total'], 'untranslated' => $stats['untranslated'], 'translated' => $stats['translated'], 'percentage' => $stats['percentage']); if ($stats['percentage'] >= 70) { $globalStats['70+']++; } else { if ($stats['percentage'] >= 30) { $globalStats['30+']++; } else { if ($stats['percentage'] < 30) { $globalStats['0+']++; } } } } } // output translation percentage to terminal or to a wiki page