MDL-59010 analytics: Logstores initialised during tests
authorDavid Monllao <davidm@moodle.com>
Tue, 13 Jun 2017 07:36:30 +0000 (09:36 +0200)
committerDavid Monllao <davidm@moodle.com>
Mon, 24 Jul 2017 06:36:47 +0000 (08:36 +0200)
Part of MDL-57791 epic.

analytics/classes/manager.php
analytics/tests/course_test.php
analytics/tests/prediction_test.php

index 77cc455..00771d7 100644 (file)
@@ -251,7 +251,7 @@ class manager {
     /**
      * get_analytics_logstore
      *
-     * @return \core\log\reader
+     * @return \core\log\sql_reader
      */
     public static function get_analytics_logstore() {
         $readers = get_log_manager()->get_readers('core\log\sql_reader');
index 4b93de5..2c8c618 100644 (file)
@@ -153,48 +153,4 @@ class core_analytics_course_testcase extends advanced_testcase {
     protected function time_less_than($time) {
         return $time + (WEEKSECS * 2);
     }
-
-    /**
-     * Generate a log.
-     *
-     * @param int $time
-     * @param int $userid
-     * @param int $courseid
-     * @return void
-     */
-    protected function generate_log($time, $userid = false, $courseid = false) {
-        global $DB;
-
-        if (empty($userid)) {
-            $userid = $this->stu1->id;
-        }
-        if (empty($courseid)) {
-            $courseid = $this->course->id;
-        }
-
-        $context = context_course::instance($courseid);
-        $obj = (object)[
-            'eventname' => '\\core\\event\\course_viewed',
-            'component' => 'core',
-            'action' => 'viewed',
-            'target' => 'course',
-            'objecttable' => 'course',
-            'objectid' => $courseid,
-            'crud' => 'r',
-            'edulevel' => \core\event\base::LEVEL_PARTICIPATING,
-            'contextid' => $context->id,
-            'contextlevel' => $context->contextlevel,
-            'contextinstanceid' => $context->instanceid,
-            'userid' => $userid,
-            'courseid' => $courseid,
-            'relateduserid' => null,
-            'anonymous' => 0,
-            'other' => null,
-            'timecreated' => $time,
-            'origin' => 'web',
-        ];
-        $DB->insert_record('logstore_standard_log', $obj);
-    }
-
 }
-
index 77103e4..7d1845d 100644 (file)
@@ -48,6 +48,8 @@ class core_analytics_prediction_testcase extends advanced_testcase {
     public function test_ml_training_and_prediction($timesplittingid, $npredictedranges, $predictionsprocessorclass) {
         global $DB;
 
+        set_config('enabled_stores', 'logstore_standard', 'tool_log');
+
         $ncourses = 10;
 
         $this->resetAfterTest(true);
@@ -155,6 +157,8 @@ class core_analytics_prediction_testcase extends advanced_testcase {
     public function test_ml_evaluation($modelquality, $ncourses, $expected, $predictionsprocessorclass) {
         $this->resetAfterTest(true);
 
+        set_config('enabled_stores', 'logstore_standard', 'tool_log');
+
         $sometimesplittings = '\core_analytics\local\time_splitting\weekly,' .
             '\core_analytics\local\time_splitting\single_range,' .
             '\core_analytics\local\time_splitting\quarters';