2 if (!defined('MOODLE_INTERNAL')) {
3 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
6 class UnitTestCaseUsingDatabase_test
extends UnitTestCaseUsingDatabase
{
8 function test_stuff() {
10 $dbman = $this->testdb
->get_manager();
12 $this->assertFalse($dbman->table_exists('quiz_attempts'));
13 $this->assertFalse($dbman->table_exists('quiz'));
14 $this->create_test_table('quiz_attempts', 'mod/quiz');
15 $this->assertTrue($dbman->table_exists('quiz_attempts'));
16 $this->assertFalse($dbman->table_exists('quiz'));
18 $this->load_test_data('quiz_attempts',
19 array('quiz', 'uniqueid', 'attempt', 'preview', 'layout'), array(
20 array( 1 , 1 , 1 , 0 , '1,2,3,0'),
21 array( 1 , 2 , 2 , 1 , '2,3,1,0')));
23 $this->switch_to_test_db();
24 require_once($CFG->dirroot
. '/mod/quiz/locallib.php');
25 $this->assertTrue(quiz_has_attempts(1));
26 $this->revert_to_real_db();
28 $this->drop_test_table('quiz_attempts');
29 $this->assertFalse($dbman->table_exists('quiz_attempts'));