Example #1
0
 /**
  * Method called after each test method. Doesn't do anything extraordinary except restore the global $DB to the real one.
  */
 public function tearDown()
 {
     global $CFG;
     $CFG->enableavailability = $this->oldcfg->enableavailability;
     $CFG->enablecompletion = $this->oldcfg->enablecompletion;
     parent::tearDown();
     // All the test tables created in setUp will be dropped by this
 }
Example #2
0
    public function setUp() {
        parent::setUp();

        $this->switch_to_test_db(); // Switch to test DB for all the execution

        foreach ($this->testtables as $dir => $tables) {
            $this->create_test_tables($tables, $dir); // Create tables
        }
    }
 /**
  * Create temporary test tables and entries in the database for these tests.
  * These tests have to work on a brand new site.
  */
 public function setUp()
 {
     global $CFG;
     parent::setup();
     // All operations until end of test method will happen in test DB
     $this->switch_to_test_db();
     foreach ($this->tables as $dir => $tables) {
         $this->create_test_tables($tables, $dir);
         // Create tables
         foreach ($tables as $table) {
             // Fill them if load_xxx method is available
             $function = "load_{$table}";
             if (method_exists($this, $function)) {
                 $this->{$function}();
             }
         }
     }
 }
Example #4
0
 public function tearDown()
 {
     parent::tearDown();
 }
 public function tearDown()
 {
     global $COURSE;
     $this->testpage = NULL;
     $COURSE = $this->originalcourse;
     parent::tearDown();
 }
Example #6
0
 public function tearDown() {
     global $CFG;
     // Recover original frontpageroleid
     $CFG->defaultfrontpageroleid = $this->originaldefaultfrontpageroleid;
     parent::tearDown();
 }
 function tearDown()
 {
     parent::tearDown();
     // All the test tables created in setUp will be dropped by this
 }
 public function tearDown()
 {
     global $USER;
     if (!empty($this->isediting)) {
         // Replace $USER->editing as it was there at setup.
         $USER->editing = $this->isediting;
         $this->isediting = null;
     }
     parent::tearDown();
 }
 public function tearDown()
 {
     $CFG->stringfilters = $this->origcfgstringfilters;
     $CFG->filterall = $this->origcfgfilterall;
     parent::tearDown();
 }
 public function tearDown()
 {
     global $USER, $SITE;
     if (isset($this->accesslibprevuser)) {
         $USER = $this->accesslibprevuser;
     }
     if (isset($this->accesslibprevsite)) {
         $SITE = $this->accesslibprevsite;
     }
     parent::tearDown();
 }
 public function tearDown()
 {
     parent::tearDown();
     // In charge of droppng all the test tables
 }
 /**
  * Tear Down function. Here we remove all the database entries that we created
  * for testing the unit tests.
  */
 public function tearDown() {
     $this->revert_to_real_db();
     parent::tearDown();
 }
Example #13
0
 function tearDown()
 {
     global $USER;
     $USER = $this->olduser;
     parent::tearDown();
 }
Example #14
0
 function setup()
 {
     parent::setup();
 }
 public function setUp()
 {
     global $ACCESSLIB_PRIVATE;
     parent::setUp();
     // All operations until end of test method will happen in test DB
     $this->switch_to_test_db();
     foreach ($this->tables as $dir => $tables) {
         $this->create_test_tables($tables, $dir);
         // Create tables
     }
     // clear context cache for testing with dummy system context etc
     $ACCESSLIB_PRIVATE->contexcache = new context_cache();
     $context = new stdClass();
     $context->contextlevel = CONTEXT_SYSTEM;
     $context->instanceid = 0;
     $context->depth = 1;
     $context->path = null;
     //not known before insert
     $context->id = $this->testdb->insert_record('context', $context);
     $context->path = '/' . $context->id;
     $this->testdb->update_record('context', $context);
     $ACCESSLIB_PRIVATE->systemcontext = $context->id;
     $this->load_course_category();
     $this->load_modules();
     $this->load_roles();
     $this->load_capabilities();
     $this->load_role_capabilities();
     // load test courses and contexts
     $this->courses['single'] = $this->get_new_course(0);
     $this->contexts['single'] = get_context_instance(CONTEXT_COURSE, $this->courses['single']->id);
     $this->courses['group'] = $this->get_new_course(1);
     $this->contexts['group'] = get_context_instance(CONTEXT_COURSE, $this->courses['group']->id);
     $this->admin = $this->get_new_user('admin');
     $this->teacher = $this->get_new_user('editingteacher');
     $this->student = $this->get_new_user('student');
     $this->nouser = $this->get_new_user(null);
     // this user will have no role in courses
 }