Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 40... Línea 40...
40
 * @package   core
40
 * @package   core
41
 * @category  test
41
 * @category  test
42
 * @copyright 2013 David Mudrak <david@moodle.com>
42
 * @copyright 2013 David Mudrak <david@moodle.com>
43
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
43
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
44
 */
44
 */
45
class string_manager_standard_test extends \advanced_testcase {
45
final class string_manager_standard_test extends \advanced_testcase {
Línea 46... Línea 46...
46
 
46
 
47
    public function test_string_manager_instance(): void {
47
    public function test_string_manager_instance(): void {
Línea 48... Línea 48...
48
        $this->resetAfterTest();
48
        $this->resetAfterTest();
Línea 81... Línea 81...
81
 
81
 
82
        // Check non-deprecated string.
82
        // Check non-deprecated string.
Línea 83... Línea 83...
83
        $this->assertFalse($stringman->string_deprecated('hidden', 'grades'));
83
        $this->assertFalse($stringman->string_deprecated('hidden', 'grades'));
84
 
84
 
85
        // Check deprecated string, make sure to update once that chosen below is finally removed.
85
        // Check deprecated string, make sure to update once that chosen below is finally removed.
86
        $this->assertTrue($stringman->string_deprecated('selectdevice', 'core_admin'));
86
        $this->assertTrue($stringman->string_deprecated('importantupdates_title', 'core_admin'));
-
 
87
        $this->assertTrue($stringman->string_exists('importantupdates_title', 'core_admin'));
-
 
88
        $this->assertDebuggingNotCalled();
87
        $this->assertTrue($stringman->string_exists('selectdevice', 'core_admin'));
89
        $this->assertEquals(
-
 
90
            'Important update about Chat and Survey activities',
88
        $this->assertDebuggingNotCalled();
91
            get_string('importantupdates_title', 'core_admin')
89
        $this->assertEquals('Select device', get_string('selectdevice', 'core_admin'));
92
        );
-
 
93
        $this->assertDebuggingCalled('String [importantupdates_title,core_admin] is deprecated. '.
90
        $this->assertDebuggingCalled('String [selectdevice,core_admin] is deprecated. '.
94
            'Either you should no longer be using that string, or the string has been incorrectly deprecated, '.
91
            'Either you should no longer be using that string, or the string has been incorrectly deprecated, in which case you should report this as a bug. '.
95
            'in which case you should report this as a bug. '.
Línea 92... Línea 96...
92
            'Please refer to https://moodledev.io/general/projects/api/string-deprecation');
96
            'Please refer to https://moodledev.io/general/projects/api/string-deprecation');
93
    }
97
    }
94
 
98
 
95
    /**
99
    /**
96
     * Return all deprecated strings.
100
     * Return all deprecated strings.
97
     *
101
     *
98
     * @return array
102
     * @return array
Línea 99... Línea 103...
99
     */
103
     */
100
    public function get_deprecated_strings_provider() {
104
    public static function get_deprecated_strings_provider(): array {
101
        global $CFG;
105
        global $CFG;
102
 
-
 
103
        $teststringman = testable_core_string_manager::instance($CFG->langotherroot, $CFG->langlocalroot, array());
-
 
104
        $allstrings = $teststringman->get_all_deprecated_strings();
106
 
Línea 105... Línea 107...
105
        return array_map(function($string) {
107
        $teststringman = testable_core_string_manager::instance($CFG->langotherroot, $CFG->langlocalroot, []);
106
            return [$string];
108
        $allstrings = $teststringman->get_all_deprecated_strings();
107
        }, $allstrings);
109
        return array_map(fn ($string): array => [$string], $allstrings);