MDL-10065 move lib/simpletest/grade/simpletest elsewhere

+ fixed categroy locking unittest and minor problem with return value
This commit is contained in:
skodak 2007-07-17 14:25:20 +00:00
parent e8513d2ca0
commit 2a8c101f69
8 changed files with 6 additions and 10 deletions

View File

@ -905,23 +905,19 @@ class grade_category extends grade_object {
* Sets the grade_item's locked variable and updates the grade_item.
* Method named after grade_item::set_locked().
* @param int $locked 0, 1 or a timestamp int(10) after which date the item will be locked.
* @return boolean success
* @return boolean success if categroy locked (not all children mayb be locked though)
*/
function set_locked($lockedstate) {
$this->load_grade_item();
$result = $this->grade_item->set_locked($lockedstate);
if ($children = grade_item::fetch_all(array('categoryid'=>$this->id))) {
foreach($children as $child) {
if (!$child->set_locked($lockedstate)) {
$result = false;
}
$child->set_locked($lockedstate);
}
}
if ($children = grade_category::fetch_all(array('parent'=>$this->id))) {
foreach($children as $child) {
if (!$child->set_locked($lockedstate)) {
$result = false;
}
$child->set_locked($lockedstate);
}
}
return $result;

View File

@ -289,8 +289,7 @@ class grade_category_test extends grade_test {
function test_grade_category_set_locked() {
$category = new grade_category($this->grade_categories[0]);
$this->assertTrue(method_exists($category, 'set_locked'));
$category->load_grade_item();
$this->assertEqual($category->set_locked(1), $category->grade_item->set_locked(1));
$this->assertTrue($category->set_locked(1));
}
function test_grade_category_is_hidden() {
@ -303,8 +302,9 @@ class grade_category_test extends grade_test {
function test_grade_category_set_hidden() {
$category = new grade_category($this->grade_categories[0]);
$this->assertTrue(method_exists($category, 'set_hidden'));
$category->set_hidden(1);
$category->load_grade_item();
$this->assertEqual($category->set_hidden(1), $category->grade_item->set_hidden(1));
$this->assertEqual(true, $category->grade_item->is_hidden());
}
function test_grade_category_has_children() {