/**
  * This function tests the whole class wiki_page.
  */
 function test_wiki_page()
 {
     $wiki_page = new stdClass();
     // Create a default wiki_page.
     $wiki_page->pagename = "[GET]SimpleTest Name";
     $wiki_page->version = 2;
     $wiki_page->content = "This is the wiki page content.";
     $wiki_page->author = "Laura";
     $wiki_page->userid = 3;
     // Test with past time: Wednesday, 30 May 2007 19:42
     $wiki_page->created = 1180546919;
     $wiki_page->lastmodified = 1180546944;
     $wiki_page->refs = "http://morfeo.upc.es/crom/course/view.php?id=4";
     $wiki_page->hits = 1;
     $wiki_page->editable = 1;
     $wiki_page->highlight = 1;
     $wiki_page->dfwiki = 25;
     $wiki_page->editor = "nwiki";
     $wiki_page->groupid = 0;
     $wiki_page->ownerid = 0;
     $wiki_page->evaluation = "";
     $id_page = insert_record("wiki_pages", $wiki_page);
     $wiki_page->id = $id_page;
     $wiki_page_object = new wiki_page(RECORD, $wiki_page);
     // Test part of gets methods from wiki page class.
     $message = '[GET] Whether wiki page identifiers are equals';
     $this->assertEqual($id_page, $wiki_page_object->id, $message);
     $message = '[GET] Whether wiki page names are equals';
     $this->assertEqual($wiki_page->pagename, $wiki_page_object->page_name(), $message);
     $message = '[GET] Whether wiki page versions are equals';
     $this->assertEqual($wiki_page->version, $wiki_page_object->version(), $message);
     $message = '[GET] Whether wiki page authors are equals';
     $this->assertEqual($wiki_page->author, $wiki_page_object->author(), $message);
     $message = '[GET] Whether wiki page user ids are equals';
     $this->assertEqual($wiki_page->userid, $wiki_page_object->user_id(), $message);
     $message = '[GET] Whether wiki page createds are equals';
     $this->assertEqual($wiki_page->created, $wiki_page_object->created(), $message);
     $message = '[GET] Whether wiki page lastmodifieds are equals';
     $this->assertEqual($wiki_page->lastmodified, $wiki_page_object->last_modified(), $message);
     $message = '[GET] Whether wiki page refs are equals';
     $this->assertEqual($wiki_page->refs, $wiki_page_object->refs(), $message);
     $message = '[GET] Whether wiki page hits are equals';
     $this->assertEqual($wiki_page->hits, $wiki_page_object->hits(), $message);
     $message = '[GET] Whether wiki page editables are equals';
     $this->assertEqual($wiki_page->editable, $wiki_page_object->editable(), $message);
     $message = '[GET] Whether wiki page highlights are equals';
     $this->assertEqual($wiki_page->highlight, $wiki_page_object->high_light(), $message);
     $message = '[GET] Whether wiki page dfwikis are equals';
     $this->assertEqual($wiki_page->dfwiki, $wiki_page_object->dfwiki(), $message);
     $message = '[GET] Whether wiki page editors are equals';
     $this->assertEqual($wiki_page->editor, $wiki_page_object->editor(), $message);
     $message = '[GET] Whether wiki page group ids are equals';
     $this->assertEqual($wiki_page->groupid, $wiki_page_object->group_id(), $message);
     $message = '[GET] Whether wiki page owner ids are equals';
     $this->assertEqual($wiki_page->ownerid, $wiki_page_object->owner_id(), $message);
     $message = '[GET] Whether wiki page editors are equals';
     $this->assertEqual($wiki_page->evaluation, $wiki_page_object->evaluation(), $message);
     // Test part of sets methods from wiki page class.
     // We store refs string to test set function of add refs.
     $refs_str = $wiki_page->refs;
     // Create another wiki to set the old one.
     $wiki_page->id = 777;
     $wiki_page->pagename = "[SET]SimpleTest Name";
     $wiki_page->version = 3;
     $wiki_page->content = "This is the wiki page content for set test.";
     $wiki_page->author = "LM";
     $wiki_page->userid = 4;
     // Test with past time: Wednesday, 30 May 2007 19:42
     $wiki_page->created = 1180546829;
     $wiki_page->lastmodified = 1180546945;
     $wiki_page->refs = "http://morfeo.upc.es/crom/course/view.php?id=2";
     // Needed to set add refs
     $refs_str = $refs_str + "|" + $wiki_page->refs;
     $wiki_page->hits = 0;
     $wiki_page->editable = 0;
     $wiki_page->highlight = 0;
     $wiki_page->dfwiki = 50;
     $wiki_page->editor = "nwiki";
     $wiki_page->groupid = 0;
     $wiki_page->ownerid = 0;
     $wiki_page->evaluation = "";
     $message = '[SET] Whether wiki page identifiers are equals';
     $wiki_page_object->set_id($wiki_page->id);
     $this->assertEqual($wiki_page->id, $wiki_page_object->id, $message);
     $message = '[SET] Whether page names are equals';
     $wiki_page_object->set_page_name($wiki_page->pagename);
     $this->assertEqual($wiki_page->pagename, $wiki_page_object->page_name(), $message);
     $message = '[SET] Whether page versions are equals';
     $wiki_page_object->set_version($wiki_page->version);
     $this->assertEqual($wiki_page->version, $wiki_page_object->version(), $message);
     $message = '[SET] Whether page versions incremented are equals';
     $wiki_page_object->inc_version();
     $this->assertEqual($wiki_page->version + 1, $wiki_page_object->version(), $message);
     $message = '[SET] Whether page contents are equals';
     $wiki_page_object->set_content($wiki_page->content);
     $this->assertEqual($wiki_page->content, $wiki_page_object->content(), $message);
     $message = '[SET] Whether page authors are equals';
     $wiki_page_object->set_author($wiki_page->author);
     $this->assertEqual($wiki_page->author, $wiki_page_object->author(), $message);
     $message = '[SET] Whether page users ids are equals';
     $wiki_page_object->set_user_id($wiki_page->userid);
     $this->assertEqual($wiki_page->userid, $wiki_page_object->user_id(), $message);
     $message = '[SET] Whether page createds are equals';
     $wiki_page_object->set_created($wiki_page->created);
     $this->assertEqual($wiki_page->created, $wiki_page_object->created(), $message);
     $message = '[SET] Whether page last modifieds are equals';
     $wiki_page_object->set_last_modified($wiki_page->lastmodified);
     $this->assertEqual($wiki_page->lastmodified, $wiki_page_object->last_modified(), $message);
     $message = '[SET] Whether page refs are equals';
     $wiki_page_object->set_refs($wiki_page->refs);
     $this->assertEqual($wiki_page->refs, $wiki_page_object->refs(), $message);
     $message = '[SET] Whether page added refs are equals';
     $wiki_page_object->add_refs($wiki_page->refs);
     $this->assertEqual($refs_str, $wiki_page_object->refs(), $message);
     $message = '[SET] Whether page hits are equals';
     $wiki_page_object->set_hits($wiki_page->hits);
     $this->assertEqual($wiki_page->hits, $wiki_page_object->hits(), $message);
     $message = '[SET] Whether page ediotables are equals';
     $wiki_page_object->set_editable($wiki_page->editable);
     $this->assertEqual($wiki_page->editable, $wiki_page_object->editable(), $message);
     $message = '[SET] Whether page owners ids are equals';
     $wiki_page_object->set_owner_id($wiki_page->ownerid);
     $this->assertEqual($wiki_page->ownerid, $wiki_page_object->owner_id(), $message);
     $message = '[SET] Whether page evaluations are equals';
     $wiki_page_object->set_evaluation($wiki_page->evaluation);
     $this->assertEqual($wiki_page->evaluation, $wiki_page_object->evaluation(), $message);
     // Delete the row inserted at the begining of the test.
     delete_records("wiki_pages", 'id', $id_page);
 }