Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 20... Línea 20...
20
 * Recycle bin category tests.
20
 * Recycle bin category tests.
21
 *
21
 *
22
 * @package    tool_recyclebin
22
 * @package    tool_recyclebin
23
 * @copyright  2015 University of Kent
23
 * @copyright  2015 University of Kent
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
25
 * @covers     \tool_recyclebin\category_bin
25
 */
26
 */
26
class category_bin_test extends \advanced_testcase {
27
final class category_bin_test extends \advanced_testcase {
Línea 27... Línea 28...
27
 
28
 
28
    /**
29
    /**
29
     * @var \stdClass $course
30
     * @var \stdClass $course
30
     */
31
     */
Línea 37... Línea 38...
37
 
38
 
38
    /**
39
    /**
39
     * Setup for each test.
40
     * Setup for each test.
40
     */
41
     */
-
 
42
    protected function setUp(): void {
41
    protected function setUp(): void {
43
        parent::setUp();
42
        $this->resetAfterTest();
44
        $this->resetAfterTest();
Línea 43... Línea 45...
43
        $this->setAdminUser();
45
        $this->setAdminUser();
44
 
46
 
Línea 71... Línea 73...
71
        // Try with the API.
73
        // Try with the API.
72
        $recyclebin = new \tool_recyclebin\category_bin($this->course->category);
74
        $recyclebin = new \tool_recyclebin\category_bin($this->course->category);
73
        $this->assertEquals(1, count($recyclebin->get_items()));
75
        $this->assertEquals(1, count($recyclebin->get_items()));
74
    }
76
    }
Línea -... Línea 77...
-
 
77
 
-
 
78
    public function test_delete_course_with_long_names(): void {
-
 
79
        global $DB;
-
 
80
 
-
 
81
        // Create a course with its name at the upper limit of what is allowed.
-
 
82
        $course = $this->getDataGenerator()->create_course([
-
 
83
            'shortname' => str_repeat("S", \core_course\constants::SHORTNAME_MAXIMUM_LENGTH),
-
 
84
            'fullname' => str_repeat("F", \core_course\constants::FULLNAME_MAXIMUM_LENGTH),
-
 
85
        ]);
-
 
86
 
-
 
87
        // Should have nothing in the recycle bin.
-
 
88
        $this->assertEquals(0, $DB->count_records('tool_recyclebin_category'));
-
 
89
 
-
 
90
        delete_course($course, false);
-
 
91
 
-
 
92
        // Verify the course is now in the recycle bin.
-
 
93
        $recyclebin = new \tool_recyclebin\category_bin($course->category);
-
 
94
        $this->assertCount(1, $recyclebin->get_items());
-
 
95
    }
75
 
96
 
76
    /**
97
    /**
77
     * Check that our hook is called when a course is deleted.
98
     * Check that our hook is called when a course is deleted.
78
     */
99
     */
79
    public function test_pre_course_category_delete_hook(): void {
100
    public function test_pre_course_category_delete_hook(): void {
Línea 173... Línea 194...
173
     * Provider for test_course_restore_with_userdata() and test_course_restore_without_userdata()
194
     * Provider for test_course_restore_with_userdata() and test_course_restore_without_userdata()
174
     *
195
     *
175
     * Used to verify that recycle bin is immune to various settings. Provides plugin, name, value for
196
     * Used to verify that recycle bin is immune to various settings. Provides plugin, name, value for
176
     * direct usage with set_config()
197
     * direct usage with set_config()
177
     */
198
     */
178
    public function recycle_bin_settings_provider() {
199
    public static function recycle_bin_settings_provider(): array {
179
        return [
200
        return [
180
            'backup/backup_auto_storage moodle' => [[
201
            'backup/backup_auto_storage moodle' => [[
181
                (object)['plugin' => 'backup', 'name' => 'backup_auto_storage', 'value' => 0],
202
                (object)['plugin' => 'backup', 'name' => 'backup_auto_storage', 'value' => 0],
182
            ]],
203
            ]],