From 1994d890c960e9350c0b74100ba72fca8dbec321 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Sat, 27 Oct 2007 10:13:25 +0000 Subject: [PATCH] Fixing unit test failures --- lib/grade/grade_category.php | 9 +- lib/grade/grade_grade.php | 2 +- lib/grade/grade_item.php | 10 +- lib/grade/simpletest/testgradecategory.php | 15 +- lib/grade/simpletest/testgradegrades.php | 13 +- lib/grade/simpletest/testgradeitem.php | 2 +- lib/simpletest/fixtures/gradetest.php | 266 +++++++++++++++++---- lib/simpletest/testbackuplib.php | 6 +- 8 files changed, 249 insertions(+), 74 deletions(-) diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php index b34792e973..c5c2824be8 100644 --- a/lib/grade/grade_category.php +++ b/lib/grade/grade_category.php @@ -364,7 +364,7 @@ class grade_category extends grade_object { /** * Generates and saves raw_grades in associated category grade item. - * These immediate children must alrady have their own final grades. + * These immediate children must already have their own final grades. * The category's aggregation method is used to generate raw grades. * * Please note that category grade is either calculated or aggregated - not both at the same time. @@ -446,6 +446,13 @@ class grade_category extends grade_object { /** * internal function for category grades aggregation + * + * @param int $userid + * @param array $items + * @param array $grade_values + * @param float $oldgrade + * @param bool $excluded + * @return boolean (just plain return;) */ function aggregate_grades($userid, $items, $grade_values, $oldgrade, $excluded) { global $CFG; diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php index 14c683fc90..646324f2a0 100644 --- a/lib/grade/grade_grade.php +++ b/lib/grade/grade_grade.php @@ -7,7 +7,7 @@ // Moodle - Modular Object-Oriented Dynamic Learning Environment // // http://moodle.com // // // -// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index f19414362a..4ad8937a85 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -7,7 +7,7 @@ // Moodle - Modular Object-Oriented Dynamic Learning Environment // // http://moodle.com // // // -// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -1250,7 +1250,7 @@ class grade_item extends grade_object { } /** - * Refetch grades from moudles, plugins. + * Refetch grades from modules, plugins. * @param int $userid optional, one user only */ function refresh_grades($userid=0) { @@ -1261,12 +1261,12 @@ class grade_item extends grade_object { } if (!$activity = get_record($this->itemmodule, 'id', $this->iteminstance)) { - debugging('Can not find activity'); + debugging("Can not find $this->itemmodule activity with id $this->iteminstance"); return; } - if (! $cm = get_coursemodule_from_instance($this->itemmodule, $activity->id, $this->courseid)) { - debuggin('Can not find course module'); + if (!$cm = get_coursemodule_from_instance($this->itemmodule, $activity->id, $this->courseid)) { + debugging('Can not find course module'); return; } diff --git a/lib/grade/simpletest/testgradecategory.php b/lib/grade/simpletest/testgradecategory.php index c0f819f6c5..c907413171 100755 --- a/lib/grade/simpletest/testgradecategory.php +++ b/lib/grade/simpletest/testgradecategory.php @@ -7,7 +7,7 @@ // Moodle - Modular Object-Oriented Dynamic Learning Environment // // http://moodle.org // // // -// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -222,15 +222,16 @@ class grade_category_test extends grade_test { $category->generate_grades(); $grades = get_records('grade_grades', 'itemid', $category->grade_item->id); $this->assertEqual(3, count($grades)); - - $rawvalues = array(); + + // Category grades do not have raw values + $finalvalues = array(); foreach ($grades as $grade) { - $this->assertWithinMargin($grade->rawgrade, $grade->rawgrademin, $grade->rawgrademax); - $rawvalues[] = (int)$grade->rawgrade; + $this->assertWithinMargin($grade->finalgrade, $grade->rawgrademin, $grade->rawgrademax); + $finalvalues[] = (int)$grade->finalgrade; } - sort($rawvalues); + sort($finalvalues); // calculated mean results - $this->assertEqual($rawvalues, array(20,50,100)); + $this->assertEqual($finalvalues, array(20,50,100)); } function test_grade_category_aggregate_grades() { diff --git a/lib/grade/simpletest/testgradegrades.php b/lib/grade/simpletest/testgradegrades.php index 5ec8f32de1..33cbe36312 100755 --- a/lib/grade/simpletest/testgradegrades.php +++ b/lib/grade/simpletest/testgradegrades.php @@ -7,7 +7,7 @@ // Moodle - Modular Object-Oriented Dynamic Learning Environment // // http://moodle.org // // // -// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -122,17 +122,20 @@ class grade_grade_test extends grade_test { $this->assertTrue(empty($grade_item->locked)); $this->assertTrue(empty($grade->locked)); - + + // Test locking the grade $this->assertTrue($grade->set_locked(true)); $this->assertFalse(empty($grade->locked)); $this->assertTrue($grade->set_locked(false)); $this->assertTrue(empty($grade->locked)); - $this->assertTrue($grade_item->set_locked(true)); + // Test locking the grade item with cascading on + $this->assertTrue($grade_item->set_locked(true, true, false)); $grade = new grade_grade($grade_item->get_final(1)); - $this->assertFalse(empty($grade->locked)); - $this->assertFalse($grade->set_locked(false)); + // Grade should already be locked + $this->assertFalse(empty($grade->locked)); + $this->assertTrue($grade->set_locked(false)); $this->assertTrue($grade_item->set_locked(false)); $grade = new grade_grade($grade_item->get_final(1)); diff --git a/lib/grade/simpletest/testgradeitem.php b/lib/grade/simpletest/testgradeitem.php index 80ae19bf79..520417888f 100755 --- a/lib/grade/simpletest/testgradeitem.php +++ b/lib/grade/simpletest/testgradeitem.php @@ -355,7 +355,7 @@ class grade_item_test extends grade_test { $this->assertTrue(empty($grade_item->locked)); $this->assertTrue(empty($grade->locked)); - $this->assertTrue($grade_item->set_locked(true)); + $this->assertTrue($grade_item->set_locked(true, true)); $grade = new grade_grade($grade_item->get_final(1)); $this->assertFalse(empty($grade_item->locked)); diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php index c9274f9423..63b8d683bb 100644 --- a/lib/simpletest/fixtures/gradetest.php +++ b/lib/simpletest/fixtures/gradetest.php @@ -7,7 +7,7 @@ // Moodle - Modular Object-Oriented Dynamic Learning Environment // // http://moodle.org // // // -// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -51,19 +51,29 @@ class grade_test extends UnitTestCase { * every test has access to these test data. The order of the following array is * crucial, because of the interrelationships between objects. */ - var $tables = array('grade_categories', + var $tables = array('modules', + 'quiz', + 'assignment', + 'forum', + 'course_modules', + 'grade_categories', 'scale', 'grade_items', 'grade_grades', - 'grade_outcomes'); + 'grade_outcomes' + ); var $grade_items = array(); var $grade_categories = array(); var $grade_grades = array(); var $grade_outcomes = array(); var $scale = array(); + var $modules = array(); + var $course_modules = array(); - var $activities = array(); + var $assignments = array(); + var $quizzes = array(); + var $forums = array(); var $courseid = 1; var $userid = 1; @@ -380,6 +390,105 @@ class grade_test extends UnitTestCase { } else { delete_records($table->name); } + + /// Define table quiz_grades to be created + $table = new XMLDBTable('quiz_grades'); + + if ($result && !table_exists($table)) { + + /// Adding fields to table quiz_grades + $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->addFieldInfo('quiz', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('grade', XMLDB_TYPE_FLOAT, null, null, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + + /// Adding keys to table quiz_grades + $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->addKeyInfo('quiz', XMLDB_KEY_FOREIGN, array('quiz'), 'quiz', array('id')); + + /// Adding indexes to table quiz_grades + $table->addIndexInfo('userid', XMLDB_INDEX_NOTUNIQUE, array('userid')); + + /// Launch create table for quiz_grades + $result = $result && create_table($table); + } else { + delete_records($table->name); + } + + /// Define table assignment to be created + $table = new XMLDBTable('assignment'); + + if ($result && !table_exists($table)) { + + /// Adding fields to table assignment + $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('description', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('assignmenttype', XMLDB_TYPE_CHAR, '50', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('resubmit', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('preventlate', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('emailteachers', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('var1', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0'); + $table->addFieldInfo('var2', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0'); + $table->addFieldInfo('var3', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0'); + $table->addFieldInfo('var4', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0'); + $table->addFieldInfo('var5', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0'); + $table->addFieldInfo('maxbytes', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '100000'); + $table->addFieldInfo('timedue', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('timeavailable', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('grade', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + + /// Adding keys to table assignment + $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Adding indexes to table assignment + $table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course')); + + /// Launch create table for assignment + $result = $result && create_table($table); + } else { + delete_records($table->name); + } + + /// Define table forum to be created + $table = new XMLDBTable('forum'); + + if ($result && !table_exists($table)) { + /// Adding fields to table forum + $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('type', XMLDB_TYPE_CHAR, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general'); + $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('intro', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('assessed', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('assesstimestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('assesstimefinish', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('scale', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('maxbytes', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('forcesubscribe', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('trackingtype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1'); + $table->addFieldInfo('rsstype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('rssarticles', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('warnafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('blockafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('blockperiod', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + + /// Adding keys to table forum + $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Adding indexes to table forum + $table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course')); + + /// Launch create table for forum + $result = $result && create_table($table); + } else { + delete_records($table->name); + } return $result; } @@ -812,81 +921,134 @@ class grade_test extends UnitTestCase { } } + /** + * Load test quiz data into the database + */ + function load_quiz() { + $quiz = new stdClass(); + $quiz->course = $this->courseid; + $quiz->name = 'test quiz'; + $quiz->intro = 'let us quiz you!'; + $quiz->questions = '1,2'; + if ($quiz->id = insert_record('quiz', $quiz)) { + $this->quizzes[0] = $quiz; + } else { + die("Can't create a test quiz!!!"); + } + + $quiz = new stdClass(); + $quiz->course = $this->courseid; + $quiz->name = 'test quiz 2'; + $quiz->intro = 'let us quiz you again!'; + $quiz->questions = '1,3'; + if ($quiz->id = insert_record('quiz', $quiz)) { + $this->quizzes[1] = $quiz; + } else { + die("Can't create a test quiz!!!"); + } + } + + /** + * Load test assignment data into the database + */ + function load_assignment() { + $assignment = new stdClass(); + $assignment->course = $this->courseid; + $assignment->name = 'test assignment'; + $assignment->description = 'What is the purpose of life?'; + if ($assignment->id = insert_record('assignment', $assignment)) { + $this->assignments[0] = $assignment; + } else { + die("Can't create a test assignment!!!"); + } + } + + /** + * Load test forum data into the database + */ + function load_forum() { + $forum = new stdClass(); + $forum->course = $this->courseid; + $forum->name = 'test forum 1'; + $forum->intro = 'Another test forum'; + if ($forum->id = insert_record('forum', $forum)) { + $this->forums[0] = $forum; + } else { + die("Can't create a test forum!!!"); + } + + $forum = new stdClass(); + $forum->course = $this->courseid; + $forum->name = 'test forum 2'; + $forum->intro = 'Another test forum'; + if ($forum->id = insert_record('forum', $forum)) { + $this->forums[1] = $forum; + } else { + die("Can't create a test forum!!!"); + } + + $forum = new stdClass(); + $forum->course = $this->courseid; + $forum->name = 'test forum 3'; + $forum->intro = 'Another test forum'; + if ($forum->id = insert_record('forum', $forum)) { + $this->forums[2] = $forum; + } else { + die("Can't create a test forum!!!"); + } + } + /** * Load module instance entries in course_modules table */ function load_course_modules() { $course_module = new stdClass(); $course_module->course = $this->courseid; - $quiz->module = 1; - $quiz->instance = 2; + $course_module->module = $this->modules[0]->id; + $course_module->instance = $this->assignments[0]->id; if ($course_module->id = insert_record('course_modules', $course_module)) { - $this->course_module[0] = $course_module; + $this->course_modules[0] = $course_module; } $course_module = new stdClass(); $course_module->course = $this->courseid; - $quiz->module = 2; - $quiz->instance = 1; + $course_module->module = $this->modules[1]->id; + $course_module->instance = $this->quizzes[0]->id; if ($course_module->id = insert_record('course_modules', $course_module)) { - $this->course_module[0] = $course_module; + $this->course_modules[1] = $course_module; } $course_module = new stdClass(); $course_module->course = $this->courseid; - $quiz->module = 2; - $quiz->instance = 5; + $course_module->module = $this->modules[1]->id; + $course_module->instance = $this->quizzes[1]->id; if ($course_module->id = insert_record('course_modules', $course_module)) { - $this->course_module[0] = $course_module; + $this->course_modules[2] = $course_module; } $course_module = new stdClass(); $course_module->course = $this->courseid; - $quiz->module = 3; - $quiz->instance = 3; + $course_module->module = $this->modules[2]->id; + $course_module->instance = $this->forums[0]->id; if ($course_module->id = insert_record('course_modules', $course_module)) { - $this->course_module[0] = $course_module; + $this->course_modules[3] = $course_module; } $course_module = new stdClass(); $course_module->course = $this->courseid; - $quiz->module = 3; - $quiz->instance = 7; + $course_module->module = $this->modules[2]->id; + $course_module->instance = $this->forums[1]->id; if ($course_module->id = insert_record('course_modules', $course_module)) { - $this->course_module[0] = $course_module; + $this->course_modules[4] = $course_module; } $course_module = new stdClass(); $course_module->course = $this->courseid; - $quiz->module = 3; - $quiz->instance = 9; + $course_module->module = $this->modules[2]->id; + $course_module->instance = $this->forums[2]->id; if ($course_module->id = insert_record('course_modules', $course_module)) { - $this->course_module[0] = $course_module; - } - } - - /** - * Load test quiz data into the database - */ - function load_quiz_activities() { - $quiz = new stdClass(); - $quiz->course = $this->courseid; - $quiz->name = 'test quiz'; - $quiz->intro = 'let us quiz you!'; - $quiz->questions = '1,2'; - if ($quiz->id = insert_record('quiz', $quiz)) { - $this->activities[0] = $quiz; - } - - $quiz = new stdClass(); - $quiz->course = $this->courseid; - $quiz->name = 'test quiz 2'; - $quiz->intro = 'let us quiz you again!'; - $quiz->questions = '1,3'; - if ($quiz->id = insert_record('quiz', $quiz)) { - $this->activities[1] = $quiz; + $this->course_modules[5] = $course_module; } - } /** @@ -904,7 +1066,7 @@ class grade_test extends UnitTestCase { $grade_item->itemname = 'unittestgradeitem1'; $grade_item->itemtype = 'mod'; $grade_item->itemmodule = 'quiz'; - $grade_item->iteminstance = 1; + $grade_item->iteminstance = $this->quizzes[0]->id; $grade_item->gradetype = GRADE_TYPE_VALUE; $grade_item->grademin = 30; $grade_item->grademax = 110; @@ -929,7 +1091,7 @@ class grade_test extends UnitTestCase { $grade_item->itemmodule = 'assignment'; $grade_item->calculation = '= ##gi'.$this->grade_items[0]->id.'## + 30 + [[item id 0]] - [[item id 0]]'; $grade_item->gradetype = GRADE_TYPE_VALUE; - $grade_item->iteminstance = 2; + $grade_item->iteminstance = $this->assignments[0]->id; $grade_item->itemnumber = null; $grade_item->grademin = 0; $grade_item->grademax = 100; @@ -950,7 +1112,7 @@ class grade_test extends UnitTestCase { $grade_item->itemname = 'unittestgradeitem3'; $grade_item->itemtype = 'mod'; $grade_item->itemmodule = 'forum'; - $grade_item->iteminstance = 3; + $grade_item->iteminstance = $this->forums[0]->id; $grade_item->gradetype = GRADE_TYPE_SCALE; $grade_item->scaleid = $this->scale[0]->id; $grade_item->grademin = 0; @@ -1034,7 +1196,7 @@ class grade_test extends UnitTestCase { $grade_item->itemname = 'unittestorphangradeitem1'; $grade_item->itemtype = 'mod'; $grade_item->itemmodule = 'quiz'; - $grade_item->iteminstance = 5; + $grade_item->iteminstance = $this->quizzes[1]->id; $grade_item->itemnumber = 0; $grade_item->gradetype = GRADE_TYPE_VALUE; $grade_item->grademin = 10; @@ -1058,7 +1220,7 @@ class grade_test extends UnitTestCase { $grade_item->itemname = 'singleparentitem1'; $grade_item->itemtype = 'mod'; $grade_item->itemmodule = 'forum'; - $grade_item->iteminstance = 7; + $grade_item->iteminstance = $this->forums[1]->id; $grade_item->gradetype = GRADE_TYPE_SCALE; $grade_item->scaleid = $this->scale[0]->id; $grade_item->grademin = 0; @@ -1080,7 +1242,7 @@ class grade_test extends UnitTestCase { $grade_item->itemname = 'singleparentitem2'; $grade_item->itemtype = 'mod'; $grade_item->itemmodule = 'forum'; - $grade_item->iteminstance = 9; + $grade_item->iteminstance = $this->forums[2]->id; $grade_item->gradetype = GRADE_TYPE_VALUE; $grade_item->grademin = 0; $grade_item->grademax = 100; diff --git a/lib/simpletest/testbackuplib.php b/lib/simpletest/testbackuplib.php index b237dc2097..874b5936ed 100644 --- a/lib/simpletest/testbackuplib.php +++ b/lib/simpletest/testbackuplib.php @@ -102,14 +102,16 @@ class backuplib_test extends UnitTestCase { backup_copy_user_files($preferences); // Check for the existence of the backup file - $this->assertTrue(file_exists("$CFG->dataroot/temp/backup/$preferences->backup_unique_code/user_files")); + $backupfile = "$CFG->dataroot/temp/backup/$preferences->backup_unique_code/user_files"; + $this->assertTrue(file_exists($backupfile)); // Check for the existence of the user files in the backup file foreach ($this->testfiles as $file) { $parts = explode('/', $file); $section = $parts[0]; $userid = $parts[1]; - $this->assertTrue(file_exists("$CFG->dataroot/temp/backup/$preferences->backup_unique_code/user_files/$section/$userid/f1.gif")); + $userimage = "$CFG->dataroot/temp/backup/$preferences->backup_unique_code/user_files/$section/$userid/f1.gif"; + $this->assertTrue(file_exists($userimage)); } } -- 2.39.5