/** * @test */ public function modelIsReturnedCorrectlyForSingleFile() { file_put_contents('vfs://Foo/Bar.xml', ''); $result = $this->repository->getModel('Bar'); $this->assertAttributeContains('vfs://Foo/Bar.xml', 'sourcePaths', $result); $result = $this->repository->getModel('NoSuchFile'); $this->assertEquals(false, $result); }
/** * Generates an internal representation of plural rules which can be found * in plurals.xml CLDR file. * * The properties $rulesets and $rulesetsIndices should be empty before * running this method. * * @return void * @see PluralsReader::$rulesets */ protected function generateRulesets() { $model = $this->cldrRepository->getModel('supplemental/plurals'); $pluralRulesSet = $model->getRawArray('plurals'); $index = 0; foreach ($pluralRulesSet as $pluralRulesNodeString => $pluralRules) { $localeLanguages = $model->getAttributeValue($pluralRulesNodeString, 'locales'); foreach (explode(' ', $localeLanguages) as $localeLanguage) { $this->rulesetsIndices[$localeLanguage] = $index; } if (is_array($pluralRules)) { $ruleset = []; foreach ($pluralRules as $pluralRuleNodeString => $pluralRule) { $pluralForm = $model->getAttributeValue($pluralRuleNodeString, 'count'); $ruleset[$pluralForm] = $this->parseRule($pluralRule); } foreach (explode(' ', $localeLanguages) as $localeLanguage) { $this->rulesets[$localeLanguage][$index] = $ruleset; } } ++$index; } }