Fixing unit test failures

This commit is contained in:
nicolasconnault 2007-10-27 10:13:25 +00:00
parent 96aad15ced
commit 1994d890c9
8 changed files with 263 additions and 88 deletions

View file

@ -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() {

View file

@ -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));

View file

@ -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));