/** * Return all deprecated strings. * * @return array */ public function get_deprecated_strings_provider() { global $CFG; $teststringman = testable_core_string_manager::instance($CFG->langotherroot, $CFG->langlocalroot, array()); $allstrings = $teststringman->get_all_deprecated_strings(); return array_map(function ($string) { return [$string]; }, $allstrings); }
/** * This test is a built-in validation of deprecated.txt files in lang locations. * * It will fail if the string in the wrong format or non-existing (mistyped) string was deprecated. */ public function test_validate_deprecated_strings_files() { global $CFG; $stringman = get_string_manager(); $teststringman = testable_core_string_manager::instance($CFG->langotherroot, $CFG->langlocalroot, array()); $allstrings = $teststringman->get_all_deprecated_strings(); foreach ($allstrings as $string) { if (!preg_match('/^(.*),(.*)$/', $string, $matches) || clean_param($matches[2], PARAM_COMPONENT) !== $matches[2]) { $this->fail('String "' . $string . '" appearing in one of the lang/en/deprecated.txt files does not have correct syntax'); } list($pluginttype, $pluginname) = core_component::normalize_component($matches[2]); if ($matches[2] !== $pluginttype . '_' . $pluginname) { $this->fail('String "' . $string . '" appearing in one of the lang/en/deprecated.txt files does not have normalised component name'); } if (!$stringman->string_exists($matches[1], $matches[2])) { $this->fail('String "' . $string . '" appearing in one of the lang/en/deprecated.txt files does not exist'); } } }
public function test_get_language_dependencies() { $this->resetAfterTest(); $otherroot = dirname(__FILE__) . '/fixtures/langtest'; $stringman = testable_core_string_manager::instance($otherroot); // There is no parent language for 'en'. $this->assertSame(array(), $stringman->get_language_dependencies('en')); // Language with no parent language declared. $this->assertSame(array('aa'), $stringman->get_language_dependencies('aa')); // Language with parent language explicitly set to English (en < de). $this->assertSame(array('de'), $stringman->get_language_dependencies('de')); // Language dependency hierarchy (de < de_du < de_kids). $this->assertSame(array('de', 'de_du', 'de_kids'), $stringman->get_language_dependencies('de_kids')); // Language with the parent language misconfigured to itself (sd < sd). $this->assertSame(array('sd'), $stringman->get_language_dependencies('sd')); // Language with circular dependency (cda < cdb < cdc < cda). $this->assertSame(array('cda', 'cdb', 'cdc'), $stringman->get_language_dependencies('cdc')); // Orphaned language (N/A < bb). $this->assertSame(array('bb'), $stringman->get_language_dependencies('bb')); // Descendant of an orphaned language (N/A < bb < bc). $this->assertSame(array('bb', 'bc'), $stringman->get_language_dependencies('bc')); }