| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: testgradeoutcome.php,v 1.2.2.1 2008/03/06 13:44:47 nicolasconnault Exp $ 2 3 /////////////////////////////////////////////////////////////////////////// 4 // // 5 // NOTICE OF COPYRIGHT // 6 // // 7 // Moodle - Modular Object-Oriented Dynamic Learning Environment // 8 // http://moodle.org // 9 // // 10 // Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // 11 // // 12 // This program is free software; you can redistribute it and/or modify // 13 // it under the terms of the GNU General Public License as published by // 14 // the Free Software Foundation; either version 2 of the License, or // 15 // (at your option) any later version. // 16 // // 17 // This program is distributed in the hope that it will be useful, // 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 20 // GNU General Public License for more details: // 21 // // 22 // http://www.gnu.org/copyleft/gpl.html // 23 // // 24 /////////////////////////////////////////////////////////////////////////// 25 26 /** 27 * Unit tests for grade_outcome object. 28 * 29 * @author nicolas@moodle.com 30 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 31 * @package moodlecore 32 */ 33 34 if (!defined('MOODLE_INTERNAL')) { 35 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page 36 } 37 38 require_once($CFG->libdir.'/simpletest/fixtures/gradetest.php'); 39 40 class grade_outcome_test extends grade_test { 41 42 function test_grade_outcome_construct() { 43 $params = new stdClass(); 44 45 $params->courseid = $this->courseid; 46 $params->shortname = 'Team work'; 47 48 $grade_outcome = new grade_outcome($params, false); 49 $this->assertEqual($params->courseid, $grade_outcome->courseid); 50 $this->assertEqual($params->shortname, $grade_outcome->shortname); 51 } 52 53 function test_grade_outcome_insert() { 54 $grade_outcome = new grade_outcome(); 55 $this->assertTrue(method_exists($grade_outcome, 'insert')); 56 57 $grade_outcome->courseid = $this->courseid; 58 $grade_outcome->shortname = 'tw'; 59 $grade_outcome->fullname = 'Team work'; 60 61 $grade_outcome->insert(); 62 63 $last_grade_outcome = end($this->grade_outcomes); 64 65 $this->assertEqual($grade_outcome->id, $last_grade_outcome->id + 1); 66 $this->assertFalse(empty($grade_outcome->timecreated)); 67 $this->assertFalse(empty($grade_outcome->timemodified)); 68 } 69 70 function test_grade_outcome_update() { 71 $grade_outcome = new grade_outcome($this->grade_outcomes[0]); 72 $this->assertTrue(method_exists($grade_outcome, 'update')); 73 $grade_outcome->shortname = 'Team work'; 74 $this->assertTrue($grade_outcome->update()); 75 $shortname = get_field('grade_outcomes', 'shortname', 'id', $this->grade_outcomes[0]->id); 76 $this->assertEqual($grade_outcome->shortname, $shortname); 77 } 78 79 function test_grade_outcome_delete() { 80 $grade_outcome = new grade_outcome($this->grade_outcomes[0]); 81 $this->assertTrue(method_exists($grade_outcome, 'delete')); 82 83 $this->assertTrue($grade_outcome->delete()); 84 $this->assertFalse(get_record('grade_outcomes', 'id', $grade_outcome->id)); 85 } 86 87 function test_grade_outcome_fetch() { 88 $grade_outcome = new grade_outcome(); 89 $this->assertTrue(method_exists($grade_outcome, 'fetch')); 90 91 $grade_outcome = grade_outcome::fetch(array('id'=>$this->grade_outcomes[0]->id)); 92 $grade_outcome->load_scale(); 93 $this->assertEqual($this->grade_outcomes[0]->id, $grade_outcome->id); 94 $this->assertEqual($this->grade_outcomes[0]->shortname, $grade_outcome->shortname); 95 96 $this->assertEqual($this->scale[2]->id, $grade_outcome->scale->id); 97 } 98 99 function test_grade_outcome_fetch_all() { 100 $grade_outcome = new grade_outcome(); 101 $this->assertTrue(method_exists($grade_outcome, 'fetch_all')); 102 103 $grade_outcomes = grade_outcome::fetch_all(array()); 104 $this->assertEqual(count($this->grade_outcomes), count($grade_outcomes)); 105 } 106 } 107 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |