|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 require_once("$CFG->libdir/simpletest/portfolio_testclass.php"); 00003 require_once("$CFG->dirroot/mod/data/lib.php"); 00004 require_once("$CFG->dirroot/mod/data/locallib.php"); 00005 00006 /* 00007 * TODO: The portfolio unit tests were obselete and did not work. 00008 * They have been commented out so that they do not break the 00009 * unit tests in Moodle 2. 00010 * 00011 * At some point: 00012 * 1. These tests should be audited to see which ones were valuable. 00013 * 2. The useful ones should be rewritten using the current standards 00014 * for writing test cases. 00015 * 00016 * This might be left until Moodle 2.1 when the test case framework 00017 * is due to change. 00018 */ 00019 Mock::generate('data_portfolio_caller', 'mock_caller'); 00020 Mock::generate('portfolio_exporter', 'mock_exporter'); 00021 00022 class testDataPortfolioCallers extends portfoliolib_test { 00023 /* 00024 public static $includecoverage = array('lib/portfoliolib.php', 'mod/data/lib.php'); 00025 public $module_type = 'data'; 00026 public $modules = array(); 00027 public $entries = array(); 00028 public $caller_single; 00029 public $caller; 00030 00031 public function setUp() { 00032 global $DB, $USER; 00033 00034 parent::setUp(); 00035 00036 $settings = array('quiet' => 1, 00037 00038 'pre_cleanup' => 0, 00039 'modules_list' => array($this->module_type), 00040 'number_of_students' => 5, 00041 'students_per_course' => 5, 00042 'number_of_sections' => 1, 00043 'number_of_modules' => 1, 00044 'questions_per_course' => 0); 00045 00046 generator_generate_data($settings); 00047 00048 $this->modules = $DB->get_records($this->module_type); 00049 $first_module = reset($this->modules); 00050 $cm = get_coursemodule_from_instance($this->module_type, $first_module->id); 00051 00052 $fields = $DB->get_records('data_fields', array('dataid' => $first_module->id)); 00053 $recordid = data_add_record($first_module); 00054 foreach ($fields as $field) { 00055 $content->recordid = $recordid; 00056 $content->fieldid = $field->id; 00057 $content->content = 'test content'; 00058 $content->content1 = 'test content 1'; 00059 $content->content2 = 'test content 2'; 00060 $DB->insert_record('data_content',$content); 00061 } 00062 00063 // Callback args required: id, record, delimiter_name, exporttype 00064 $this->caller_single = parent::setup_caller('data_portfolio_caller', array('id' => $cm->id, 'record' => $recordid)); 00065 $this->caller = parent::setup_caller('data_portfolio_caller', array('id' => $cm->id)); 00066 } 00067 00068 public function tearDown() { 00069 parent::tearDown(); 00070 } 00071 00072 public function test_caller_sha1() { 00073 $sha1 = $this->caller->get_sha1(); 00074 $this->caller->prepare_package(); 00075 $this->assertEqual($sha1, $this->caller->get_sha1()); 00076 00077 $sha1 = $this->caller_single->get_sha1(); 00078 $this->caller_single->prepare_package(); 00079 $this->assertEqual($sha1, $this->caller_single->get_sha1()); 00080 } 00081 00082 public function test_caller_with_plugins() { 00083 parent::test_caller_with_plugins(); 00084 } 00085 */ 00086 }