Unit tests MDL-24980 Initial fix (no fully working yet) for portfolioaddbutton test
authorSam Marshall <s.marshall@open.ac.uk>
Mon, 8 Nov 2010 11:07:09 +0000 (11:07 +0000)
committerSam Marshall <s.marshall@open.ac.uk>
Mon, 8 Nov 2010 11:07:09 +0000 (11:07 +0000)
lib/simpletest/testportfolioaddbutton.php

index d93a37d..652e9e4 100644 (file)
@@ -37,17 +37,35 @@ if (!defined('MOODLE_INTERNAL')) {
 
 require_once($CFG->libdir . '/portfoliolib.php');
 
 
 require_once($CFG->libdir . '/portfoliolib.php');
 
-class portfoliolibaddbutton_test extends FakeDBUnitTestCase {
+class portfoliolibaddbutton_test extends UnitTestCaseUsingDatabase {
 
     public static $includecoverage = array('lib/portfoliolib.php');
 
 
     public static $includecoverage = array('lib/portfoliolib.php');
 
+    protected $testtables = array(
+                'lib' => array(
+                    'portfolio_instance', 'portfolio_instance_user'));
+    
+    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
+        }
+
+    }
+
+    public function tearDown() {
+        parent::tearDown(); // In charge of droppng all the test tables
+    }
+
     function test_set_formats() {
 
         $button = new portfolio_add_button();
         $button->set_callback_options('assignment_portfolio_caller', array('id' => 6), '/mod/assignment/locallib.php');
         $formats = array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_IMAGE);
         $button->set_formats($formats);
     function test_set_formats() {
 
         $button = new portfolio_add_button();
         $button->set_callback_options('assignment_portfolio_caller', array('id' => 6), '/mod/assignment/locallib.php');
         $formats = array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_IMAGE);
         $button->set_formats($formats);
-
         $this->assertEqual(2, count($button->get_formats()));
     }
 }
         $this->assertEqual(2, count($button->get_formats()));
     }
 }