See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package core_grades 19 * @category phpunit 20 * @copyright nicolas@moodle.com 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 defined('MOODLE_INTERNAL') || die(); 25 26 require_once (__DIR__.'/fixtures/lib.php'); 27 28 29 class core_grade_outcome_testcase extends grade_base_testcase { 30 31 public function test_grade_outcome() { 32 $this->sub_test_grade_outcome_construct(); 33 $this->sub_test_grade_outcome_insert(); 34 $this->sub_test_grade_outcome_update(); 35 $this->sub_test_grade_outcome_delete(); 36 //$this->sub_test_grade_outcome_fetch(); 37 $this->sub_test_grade_outcome_fetch_all(); 38 } 39 40 protected function sub_test_grade_outcome_construct() { 41 $params = new stdClass(); 42 43 $params->courseid = $this->courseid; 44 $params->shortname = 'Team work'; 45 46 $grade_outcome = new grade_outcome($params, false); 47 $this->assertEquals($params->courseid, $grade_outcome->courseid); 48 $this->assertEquals($params->shortname, $grade_outcome->shortname); 49 } 50 51 protected function sub_test_grade_outcome_insert() { 52 $grade_outcome = new grade_outcome(); 53 $this->assertTrue(method_exists($grade_outcome, 'insert')); 54 55 $grade_outcome->courseid = $this->courseid; 56 $grade_outcome->shortname = 'tw'; 57 $grade_outcome->fullname = 'Team work'; 58 59 $grade_outcome->insert(); 60 61 $last_grade_outcome = end($this->grade_outcomes); 62 63 $this->assertEquals($grade_outcome->id, $last_grade_outcome->id + 1); 64 $this->assertFalse(empty($grade_outcome->timecreated)); 65 $this->assertFalse(empty($grade_outcome->timemodified)); 66 } 67 68 protected function sub_test_grade_outcome_update() { 69 global $DB; 70 $grade_outcome = new grade_outcome($this->grade_outcomes[0], false); 71 $this->assertTrue(method_exists($grade_outcome, 'update')); 72 $grade_outcome->shortname = 'Team work'; 73 $this->assertTrue($grade_outcome->update()); 74 $shortname = $DB->get_field('grade_outcomes', 'shortname', array('id' => $this->grade_outcomes[0]->id)); 75 $this->assertEquals($grade_outcome->shortname, $shortname); 76 } 77 78 protected function sub_test_grade_outcome_delete() { 79 global $DB; 80 $grade_outcome = new grade_outcome($this->grade_outcomes[0], false); 81 $this->assertTrue(method_exists($grade_outcome, 'delete')); 82 83 $this->assertTrue($grade_outcome->delete()); 84 $this->assertFalse($DB->get_record('grade_outcomes', array('id' => $grade_outcome->id))); 85 } 86 87 protected function sub_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->assertEquals($this->grade_outcomes[0]->id, $grade_outcome->id); 94 $this->assertEquals($this->grade_outcomes[0]->shortname, $grade_outcome->shortname); 95 96 $this->assertEquals($this->scale[2]->id, $grade_outcome->scale->id); 97 } 98 99 protected function sub_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->assertEquals(count($this->grade_outcomes), count($grade_outcomes)); 105 } 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body