Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea -...
16
 
-
 
17
/**
-
 
18
 * Provides the {@link core_form\filetypes_util_testcase} class.
-
 
19
 *
-
 
20
 * @package     core_form
-
 
21
 * @category    test
-
 
22
 * @copyright   2017 David Mudrák <david@moodle.com>
-
 
23
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
24
 */
-
 
25
 
16
 
Línea 26... Línea -...
26
namespace core_form;
-
 
27
 
-
 
28
use advanced_testcase;
-
 
29
 
-
 
30
defined('MOODLE_INTERNAL') || die();
-
 
31
 
-
 
32
global $CFG;
17
namespace core_form;
33
 
18
 
34
/**
19
/**
-
 
20
 * Test cases for the {@link core_form\filetypes_util} class.
35
 * Test cases for the {@link core_form\filetypes_util} class.
21
 *
36
 *
22
 * @package   core_form
-
 
23
 * @copyright 2017 David Mudrak <david@moodle.com>
37
 * @copyright 2017 David Mudrak <david@moodle.com>
24
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @covers    \core_form\filetypes_util
39
 */
-
 
40
class filetypes_util_test extends advanced_testcase {
26
 */
41
 
27
final class filetypes_util_test extends \advanced_testcase {
42
    /**
28
    /**
43
     * Test normalizing list of extensions.
29
     * Test normalizing list of extensions.
44
     */
-
 
45
    public function test_normalize_file_types(): void {
30
     */
46
 
31
    public function test_normalize_file_types(): void {
Línea 47... Línea 32...
47
        $this->resetAfterTest(true);
32
        $this->resetAfterTest(true);
48
        $util = new filetypes_util();
33
        $util = new filetypes_util();
Línea 73... Línea 58...
73
 
58
 
74
    /**
59
    /**
75
     * Test MIME type formal recognition.
60
     * Test MIME type formal recognition.
76
     */
61
     */
77
    public function test_looks_like_mimetype(): void {
-
 
78
 
62
    public function test_looks_like_mimetype(): void {
79
        $this->resetAfterTest(true);
63
        $this->resetAfterTest(true);
Línea 80... Línea 64...
80
        $util = new filetypes_util();
64
        $util = new filetypes_util();
81
 
65
 
Línea 92... Línea 76...
92
 
76
 
93
    /**
77
    /**
94
     * Test getting/checking group.
78
     * Test getting/checking group.
95
     */
79
     */
96
    public function test_is_filetype_group(): void {
-
 
97
 
80
    public function test_is_filetype_group(): void {
98
        $this->resetAfterTest(true);
81
        $this->resetAfterTest(true);
Línea 99... Línea 82...
99
        $util = new filetypes_util();
82
        $util = new filetypes_util();
100
 
83
 
Línea 110... Línea 93...
110
 
93
 
111
    /**
94
    /**
112
     * Test describing list of extensions.
95
     * Test describing list of extensions.
113
     */
96
     */
114
    public function test_describe_file_types(): void {
-
 
115
 
97
    public function test_describe_file_types(): void {
116
        $this->resetAfterTest(true);
98
        $this->resetAfterTest(true);
Línea 117... Línea 99...
117
        $util = new filetypes_util();
99
        $util = new filetypes_util();
Línea 168... Línea 150...
168
 
150
 
169
    /**
151
    /**
170
     * Test expanding mime types into extensions.
152
     * Test expanding mime types into extensions.
171
     */
153
     */
172
    public function test_expand(): void {
-
 
173
 
154
    public function test_expand(): void {
174
        $this->resetAfterTest(true);
155
        $this->resetAfterTest(true);
Línea 175... Línea 156...
175
        $util = new filetypes_util();
156
        $util = new filetypes_util();
Línea 206... Línea 187...
206
 
187
 
207
    /**
188
    /**
208
     * Test checking that a type is among others.
189
     * Test checking that a type is among others.
209
     */
190
     */
210
    public function test_is_listed(): void {
-
 
211
 
191
    public function test_is_listed(): void {
212
        $this->resetAfterTest(true);
192
        $this->resetAfterTest(true);
Línea 213... Línea 193...
213
        $util = new filetypes_util();
193
        $util = new filetypes_util();
214
 
194
 
Línea 249... Línea 229...
249
 
229
 
250
    /**
230
    /**
251
     * Test getting types not present in a list.
231
     * Test getting types not present in a list.
252
     */
232
     */
253
    public function test_get_not_listed(): void {
-
 
254
 
233
    public function test_get_not_listed(): void {
255
        $this->resetAfterTest(true);
234
        $this->resetAfterTest(true);
Línea 256... Línea 235...
256
        $util = new filetypes_util();
235
        $util = new filetypes_util();
257
 
236
 
Línea 272... Línea 251...
272
 
251
 
273
    /**
252
    /**
274
     * Test populating the tree for the browser.
253
     * Test populating the tree for the browser.
275
     */
254
     */
276
    public function test_data_for_browser(): void {
-
 
277
 
255
    public function test_data_for_browser(): void {
278
        $this->resetAfterTest(true);
256
        $this->resetAfterTest(true);
Línea 279... Línea 257...
279
        $util = new filetypes_util();
257
        $util = new filetypes_util();
280
 
258
 
Línea 357... Línea 335...
357
    /**
335
    /**
358
     * Data provider for testing test_is_allowed_file_type.
336
     * Data provider for testing test_is_allowed_file_type.
359
     *
337
     *
360
     * @return array
338
     * @return array
361
     */
339
     */
362
    public function is_allowed_file_type_provider() {
340
    public static function is_allowed_file_type_provider(): array {
363
        return [
341
        return [
364
            'Filetype not in extension list' => [
342
            'Filetype not in extension list' => [
365
                'filename' => 'test.xml',
343
                'filename' => 'test.xml',
366
                'list' => '.png .jpg',
344
                'list' => '.png .jpg',
367
                'expected' => false
345
                'expected' => false
Línea 419... Línea 397...
419
    /**
397
    /**
420
     * Data provider for testing test_get_unknown_file_types.
398
     * Data provider for testing test_get_unknown_file_types.
421
     *
399
     *
422
     * @return array
400
     * @return array
423
     */
401
     */
424
    public function get_unknown_file_types_provider() {
402
    public static function get_unknown_file_types_provider(): array {
425
        return [
403
        return [
426
            'Empty list' => [
404
            'Empty list' => [
427
                'filetypes' => '',
405
                'filetypes' => '',
428
                'expected' => [],
406
                'expected' => [],
429
            ],
407
            ],