Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 24... Línea 24...
24
 *
24
 *
25
 * @package    report_loglive
25
 * @package    report_loglive
26
 * @copyright  2024 onwards Laurent David <laurent.david@moodle.com>
26
 * @copyright  2024 onwards Laurent David <laurent.david@moodle.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
28
 */
28
 */
29
class table_log_test extends advanced_testcase {
29
final class table_log_test extends advanced_testcase {
30
    /**
30
    /**
31
     * @var int The course with separate groups.
31
     * @var int The course with separate groups.
32
     */
32
     */
33
    const COURSE_SEPARATE_GROUP = 0;
33
    const COURSE_SEPARATE_GROUP = 0;
34
    /**
34
    /**
Línea 222... Línea 222...
222
     * @return void
222
     * @return void
223
     * @throws \coding_exception
223
     * @throws \coding_exception
224
     */
224
     */
225
    public function setUp(): void {
225
    public function setUp(): void {
226
        global $DB;
226
        global $DB;
-
 
227
        parent::setUp();
227
        $this->resetAfterTest();
228
        $this->resetAfterTest();
228
        $this->preventResetByRollback(); // This is to ensure that we can actually trigger event and record them in the log store.
229
        $this->preventResetByRollback(); // This is to ensure that we can actually trigger event and record them in the log store.
229
        $this->courses[self::COURSE_SEPARATE_GROUP] = $this->getDataGenerator()->create_course(['groupmode' => SEPARATEGROUPS]);
230
        $this->courses[self::COURSE_SEPARATE_GROUP] = $this->getDataGenerator()->create_course(['groupmode' => SEPARATEGROUPS]);
230
        $this->courses[self::COURSE_VISIBLE_GROUP] = $this->getDataGenerator()->create_course(['groupmode' => VISIBLEGROUPS]);
231
        $this->courses[self::COURSE_VISIBLE_GROUP] = $this->getDataGenerator()->create_course(['groupmode' => VISIBLEGROUPS]);
231
        $this->courses[self::COURSE_NO_GROUP] = $this->getDataGenerator()->create_course();
232
        $this->courses[self::COURSE_NO_GROUP] = $this->getDataGenerator()->create_course();
Línea 315... Línea 316...
315
            $filteredevents);
316
            $filteredevents);
316
        sort($expectedusers);
317
        sort($expectedusers);
317
        sort($usernames);
318
        sort($usernames);
318
        $this->assertEquals($expectedusers, $usernames);
319
        $this->assertEquals($expectedusers, $usernames);
319
    }
320
    }
-
 
321
 
-
 
322
    /**
-
 
323
     * Test getting logs for deleted courses.
-
 
324
     *
-
 
325
     * @covers \report_loglive_renderable::get_table
-
 
326
     * @return void
-
 
327
     */
-
 
328
    public function test_get_deleted_course_logs(): void {
-
 
329
        global $DB, $PAGE;
-
 
330
        $this->preventResetByRollback(); // Ensure events can be recorded in log store.
-
 
331
 
-
 
332
        // Configure log store and user.
-
 
333
        $manager = get_log_manager();
-
 
334
        $stores = $manager->get_readers();
-
 
335
        $store = $stores['logstore_standard'];
-
 
336
        $this->setUser(get_admin());
-
 
337
 
-
 
338
        // Set and delete course.
-
 
339
        $course = reset($this->courses);
-
 
340
        $deletedcourseid = $course->id;
-
 
341
        delete_course($course, false);
-
 
342
        $this->assertFalse($DB->record_exists('course', ['id' => $deletedcourseid]));
-
 
343
 
-
 
344
        // Test rendering.
-
 
345
        $PAGE->set_url('/report/loglive/index.php?id=' . $deletedcourseid);
-
 
346
        $renderable = new \report_loglive_renderable('', (int) $deletedcourseid);
-
 
347
        $table = $renderable->get_table();
-
 
348
        $store->flush();
-
 
349
        $table->query_db(100);
-
 
350
 
-
 
351
        // Confirm we have logs for the course deletion and that the filtering is correct.
-
 
352
        $this->assertNotEmpty($table->totalrows);
-
 
353
        $expectedrows = count($DB->get_records('logstore_standard_log', ['courseid' => $deletedcourseid]));
-
 
354
        $this->assertEquals($expectedrows, $table->totalrows);
-
 
355
    }
320
}
356
}