Unit tests MDL-24980 Initial fix (no fully working yet) for portfolioaddbutton test

This commit is contained in:
Sam Marshall 2010-11-08 11:07:09 +00:00
parent f7fcf4cd47
commit fc2b6316f1

View file

@ -37,17 +37,35 @@ if (!defined('MOODLE_INTERNAL')) {
require_once($CFG->libdir . '/portfoliolib.php');
class portfoliolibaddbutton_test extends FakeDBUnitTestCase {
class portfoliolibaddbutton_test extends UnitTestCaseUsingDatabase {
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);
$this->assertEqual(2, count($button->get_formats()));
}
}