Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
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/>.
16
 
17
namespace tool_moodlenet\local;
18
 
19
use tool_moodlenet\local\import_handler_info;
20
use tool_moodlenet\local\import_strategy;
21
use tool_moodlenet\local\import_strategy_file;
22
 
23
/**
24
 * Class tool_moodlenet_import_handler_info_testcase, providing test cases for the import_handler_info class.
25
 *
26
 * @package    tool_moodlenet
27
 * @category   test
28
 * @copyright  2020 Jake Dallimore <jrhdallimore@gmail.com>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
class import_handler_info_test extends \advanced_testcase {
32
 
33
    /**
34
     * Test init and the getters.
35
     *
36
     * @dataProvider handler_info_data_provider
37
     * @param string $modname the name of the mod.
38
     * @param string $description description of the mod.
39
     * @param bool $expectexception whether we expect an exception during init or not.
40
     */
11 efrain 41
    public function test_initialisation($modname, $description, $expectexception): void {
1 efrain 42
        $this->resetAfterTest();
43
        // Skip those cases we cannot init.
44
        if ($expectexception) {
45
            $this->expectException(\coding_exception::class);
46
            $handlerinfo = new import_handler_info($modname, $description, new import_strategy_file());
47
        }
48
 
49
        $handlerinfo = new import_handler_info($modname, $description, new import_strategy_file());
50
 
51
        $this->assertEquals($modname, $handlerinfo->get_module_name());
52
        $this->assertEquals($description, $handlerinfo->get_description());
53
        $this->assertInstanceOf(import_strategy::class, $handlerinfo->get_strategy());
54
    }
55
 
56
 
57
    /**
58
     * Data provider for creation of import_handler_info objects.
59
     *
60
     * @return array the data for creation of the info object.
61
     */
62
    public function handler_info_data_provider() {
63
        return [
64
            'All data present' => ['label', 'Add a label to the course', false],
65
            'Empty module name' => ['', 'Add a file resource to the course', true],
66
            'Empty description' => ['resource', '', true],
67
 
68
        ];
69
    }
70
}