public function testGetLabelMethodForDefaultLabels() { $app = new Application(); $files = $app['finder']->files()->name('labels.*.yml')->in($app['app.dir.translations']); $labelVariables = array('item' => array('number' => 1, 'counters' => array(1, 1, 1, 1, 1, 1), 'level' => 1), 'element' => array('number' => 1)); foreach ($files as $file) { $locale = substr($file->getRelativePathname(), -6, 2); // reset the application for each language because labels are cached $app = new Application(); $app['publishing.edition'] = 'edition1'; $app['publishing.book.config'] = array('book' => array('language' => $locale, 'editions' => array('edition1' => array()))); $labels = Yaml::parse($file->getPathname()); foreach ($labels['label'] as $key => $value) { // some labels (chapter and appendix) are arrays instead of strings if (is_array($value)) { foreach ($value as $i => $subLabel) { $expectedValue = $app->renderString($subLabel, $labelVariables); $labelVariables['item']['level'] = $i + 1; $this->assertEquals($expectedValue, $app->getLabel($key, $labelVariables)); } } else { $expectedValue = $app->renderString($value, $labelVariables); $this->assertEquals($expectedValue, $app->getLabel($key, $labelVariables)); } } } }