Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 36... Línea 36...
36
class external_externallib_test extends externallib_advanced_testcase {
36
class external_externallib_test extends externallib_advanced_testcase {
Línea 37... Línea 37...
37
 
37
 
38
    /**
38
    /**
39
     * Test get_string
39
     * Test get_string
40
     */
40
     */
41
    public function test_get_string() {
41
    public function test_get_string(): void {
Línea 42... Línea 42...
42
        $this->resetAfterTest(true);
42
        $this->resetAfterTest(true);
43
 
43
 
44
        $service = new \stdClass();
44
        $service = new \stdClass();
Línea 84... Línea 84...
84
    }
84
    }
Línea 85... Línea 85...
85
 
85
 
86
    /**
86
    /**
87
     * Test get_string with HTML.
87
     * Test get_string with HTML.
88
     */
88
     */
89
    public function test_get_string_containing_html() {
89
    public function test_get_string_containing_html(): void {
90
        $result = \core_external::get_string('registrationinfo');
90
        $result = \core_external::get_string('registrationinfo');
91
        $actual = external_api::clean_returnvalue(\core_external::get_string_returns(), $result);
91
        $actual = external_api::clean_returnvalue(\core_external::get_string_returns(), $result);
92
        $expected = get_string('registrationinfo', 'moodle');
92
        $expected = get_string('registrationinfo', 'moodle');
93
        $this->assertSame($expected, $actual);
93
        $this->assertSame($expected, $actual);
Línea 94... Línea 94...
94
    }
94
    }
95
 
95
 
96
    /**
96
    /**
97
     * Test get_string with arguments containing HTML.
97
     * Test get_string with arguments containing HTML.
98
     */
98
     */
99
    public function test_get_string_with_args_containing_html() {
99
    public function test_get_string_with_args_containing_html(): void {
100
        $result = \core_external::get_string('added', 'moodle', null, [['value' => '<strong>Test</strong>']]);
100
        $result = \core_external::get_string('added', 'moodle', null, [['value' => '<strong>Test</strong>']]);
101
        $actual = external_api::clean_returnvalue(\core_external::get_string_returns(), $result);
101
        $actual = external_api::clean_returnvalue(\core_external::get_string_returns(), $result);
102
        $expected = get_string('added', 'moodle', '<strong>Test</strong>');
102
        $expected = get_string('added', 'moodle', '<strong>Test</strong>');
Línea 103... Línea 103...
103
        $this->assertSame($expected, $actual);
103
        $this->assertSame($expected, $actual);
104
    }
104
    }
105
 
105
 
106
    /**
106
    /**
107
     * Test get_strings
107
     * Test get_strings
Línea 108... Línea 108...
108
     */
108
     */
Línea 109... Línea 109...
109
    public function test_get_strings() {
109
    public function test_get_strings(): void {
Línea 140... Línea 140...
140
    }
140
    }
Línea 141... Línea 141...
141
 
141
 
142
    /**
142
    /**
143
     * Test get_strings with HTML.
143
     * Test get_strings with HTML.
144
     */
144
     */
145
    public function test_get_strings_containing_html() {
145
    public function test_get_strings_containing_html(): void {
146
        $result = \core_external::get_strings([['stringid' => 'registrationinfo'], ['stringid' => 'loginaspasswordexplain']]);
146
        $result = \core_external::get_strings([['stringid' => 'registrationinfo'], ['stringid' => 'loginaspasswordexplain']]);
147
        $actual = external_api::clean_returnvalue(\core_external::get_strings_returns(), $result);
147
        $actual = external_api::clean_returnvalue(\core_external::get_strings_returns(), $result);
148
        $this->assertSame(get_string('registrationinfo', 'moodle'), $actual[0]['string']);
148
        $this->assertSame(get_string('registrationinfo', 'moodle'), $actual[0]['string']);
149
        $this->assertSame(get_string('loginaspasswordexplain', 'moodle'), $actual[1]['string']);
149
        $this->assertSame(get_string('loginaspasswordexplain', 'moodle'), $actual[1]['string']);
Línea 150... Línea 150...
150
    }
150
    }
151
 
151
 
152
    /**
152
    /**
153
     * Test get_strings with arguments containing HTML.
153
     * Test get_strings with arguments containing HTML.
154
     */
154
     */
155
    public function test_get_strings_with_args_containing_html() {
155
    public function test_get_strings_with_args_containing_html(): void {
156
        $result = \core_external::get_strings([
156
        $result = \core_external::get_strings([
157
            ['stringid' => 'added', 'stringparams' => [['value' => '<strong>Test</strong>']]],
157
            ['stringid' => 'added', 'stringparams' => [['value' => '<strong>Test</strong>']]],
158
            ['stringid' => 'loggedinas', 'stringparams' => [['value' => '<strong>Test</strong>']]]]
158
            ['stringid' => 'loggedinas', 'stringparams' => [['value' => '<strong>Test</strong>']]]]
Línea 163... Línea 163...
163
    }
163
    }
Línea 164... Línea 164...
164
 
164
 
165
    /**
165
    /**
166
     * Test get_component_strings
166
     * Test get_component_strings
167
     */
167
     */
168
    public function test_get_component_strings() {
168
    public function test_get_component_strings(): void {
169
        global $USER;
169
        global $USER;
Línea 170... Línea 170...
170
        $this->resetAfterTest(true);
170
        $this->resetAfterTest(true);
Línea 185... Línea 185...
185
    }
185
    }
Línea 186... Línea 186...
186
 
186
 
187
    /**
187
    /**
188
     * Test update_inplace_editable()
188
     * Test update_inplace_editable()
189
     */
189
     */
190
    public function test_update_inplace_editable() {
190
    public function test_update_inplace_editable(): void {
Línea 191... Línea 191...
191
        $this->resetAfterTest(true);
191
        $this->resetAfterTest(true);
192
 
192
 
193
        // Call service for component that does not have inplace_editable callback.
193
        // Call service for component that does not have inplace_editable callback.
Línea 209... Línea 209...
209
    }
209
    }
Línea 210... Línea 210...
210
 
210
 
211
    /**
211
    /**
212
     * Test update_inplace_editable with mathjax.
212
     * Test update_inplace_editable with mathjax.
213
     */
213
     */
214
    public function test_update_inplace_editable_with_mathjax() {
214
    public function test_update_inplace_editable_with_mathjax(): void {
215
        $this->resetAfterTest(true);
215
        $this->resetAfterTest(true);
Línea 216... Línea 216...
216
        $this->setAdminUser();
216
        $this->setAdminUser();
217
 
217
 
Línea 237... Línea 237...
237
        // Check editlabel is the same and has mathjax.
237
        // Check editlabel is the same and has mathjax.
238
        $this->assertStringContainsString('<span class="filter_mathjaxloader_equation">', $res['editlabel']);
238
        $this->assertStringContainsString('<span class="filter_mathjaxloader_equation">', $res['editlabel']);
239
        $this->assertEquals($editlabel, $res['editlabel']);
239
        $this->assertEquals($editlabel, $res['editlabel']);
240
    }
240
    }
Línea 241... Línea 241...
241
 
241
 
242
    public function test_get_user_dates() {
242
    public function test_get_user_dates(): void {
Línea 243... Línea 243...
243
        $this->resetAfterTest();
243
        $this->resetAfterTest();
Línea 244... Línea 244...
244
 
244