|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 if (!defined('MOODLE_INTERNAL')) { 00003 die('Direct access to this script is forbidden.'); 00004 } 00005 00006 class UnitTestCaseUsingDatabase_test extends UnitTestCaseUsingDatabase { 00007 00008 function test_stuff() { 00009 global $CFG, $DB; 00010 $dbman = $this->testdb->get_manager(); 00011 00012 $this->assertFalse($dbman->table_exists('quiz_attempts')); 00013 $this->assertFalse($dbman->table_exists('quiz')); 00014 $this->create_test_table('quiz_attempts', 'mod/quiz'); 00015 $this->assertTrue($dbman->table_exists('quiz_attempts')); 00016 $this->assertFalse($dbman->table_exists('quiz')); 00017 00018 $this->load_test_data('quiz_attempts', 00019 array('quiz', 'uniqueid', 'attempt', 'preview', 'layout'), array( 00020 array( 1 , 1 , 1 , 0 , '1,2,3,0'), 00021 array( 1 , 2 , 2 , 1 , '2,3,1,0'))); 00022 00023 $this->switch_to_test_db(); 00024 require_once($CFG->dirroot . '/mod/quiz/locallib.php'); 00025 $this->assertTrue(quiz_has_attempts(1)); 00026 $this->revert_to_real_db(); 00027 00028 $this->drop_test_table('quiz_attempts'); 00029 $this->assertFalse($dbman->table_exists('quiz_attempts')); 00030 } 00031 00032 } 00033