|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 require_once("$CFG->libdir/simpletest/portfolio_testclass.php"); 00028 require_once("$CFG->dirroot/mod/forum/lib.php"); 00029 00030 /* 00031 * TODO: The portfolio unit tests were obselete and did not work. 00032 * They have been commented out so that they do not break the 00033 * unit tests in Moodle 2. 00034 * 00035 * At some point: 00036 * 1. These tests should be audited to see which ones were valuable. 00037 * 2. The useful ones should be rewritten using the current standards 00038 * for writing test cases. 00039 * 00040 * This might be left until Moodle 2.1 when the test case framework 00041 * is due to change. 00042 */ 00043 Mock::generate('forum_portfolio_caller', 'mock_caller'); 00044 Mock::generate('portfolio_exporter', 'mock_exporter'); 00045 00046 class testForumPortfolioCallers extends portfoliolib_test { 00047 /* 00048 public static $includecoverage = array('lib/portfoliolib.php', 'mod/forum/lib.php'); 00049 public $module_type = 'forum'; 00050 public $modules = array(); 00051 public $entries = array(); 00052 public $postcaller; 00053 public $discussioncaller; 00054 00055 public function setUp() { 00056 global $DB, $USER; 00057 00058 parent::setUp(); 00059 00060 $settings = array('quiet' => 1, 00061 'verbose' => 0, 00062 00063 'pre_cleanup' => 0, 00064 'post_cleanup' => 0, 00065 'modules_list' => array($this->module_type), 00066 'discussions_per_forum' => 5, 00067 'posts_per_discussion' => 10, 00068 'number_of_students' => 5, 00069 'students_per_course' => 5, 00070 'number_of_sections' => 1, 00071 'number_of_modules' => 1, 00072 'questions_per_course' => 0); 00073 00074 generator_generate_data($settings); 00075 00076 $this->modules = $DB->get_records($this->module_type); 00077 $first_module = reset($this->modules); 00078 $cm = get_coursemodule_from_instance($this->module_type, $first_module->id); 00079 00080 $discussions = $DB->get_records('forum_discussions', array('forum' => $first_module->id)); 00081 $first_discussion = reset($discussions); 00082 00083 $posts = $DB->get_records('forum_posts', array('discussion' => $first_discussion->id)); 00084 $first_post = reset($posts); 00085 00086 $callbackargs = array('postid' => $first_post->id, 'discussionid' => $first_discussion->id); 00087 $this->postcaller = parent::setup_caller('forum_portfolio_caller', $callbackargs, $first_post->userid); 00088 00089 unset($callbackargs['postid']); 00090 $this->discussioncaller = parent::setup_caller('forum_portfolio_caller', $callbackargs, $first_post->userid); 00091 00092 } 00093 00094 public function tearDown() { 00095 parent::tearDown(); 00096 } 00097 00098 public function test_caller_sha1() { 00099 $sha1 = $this->postcaller->get_sha1(); 00100 $this->postcaller->prepare_package(); 00101 $this->assertEqual($sha1, $this->postcaller->get_sha1()); 00102 00103 $sha1 = $this->discussioncaller->get_sha1(); 00104 $this->discussioncaller->prepare_package(); 00105 $this->assertEqual($sha1, $this->discussioncaller->get_sha1()); 00106 } 00107 00108 public function test_caller_with_plugins() { 00109 parent::test_caller_with_plugins(); 00110 } 00111 */ 00112 }