Unit tests MDL-24980 Disable obsolete portfolio tests until such time as somebody...
[moodle.git] / lib / simpletest / testportfolioaddbutton.php
CommitLineData
8926f844 1<?php
ef6f0f60 2
3///////////////////////////////////////////////////////////////////////////
4// //
5// NOTICE OF COPYRIGHT //
6// //
7// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8// http://moodle.org //
9// //
10// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
11// //
12// This program is free software; you can redistribute it and/or modify //
13// it under the terms of the GNU General Public License as published by //
14// the Free Software Foundation; either version 2 of the License, or //
15// (at your option) any later version. //
16// //
17// This program is distributed in the hope that it will be useful, //
18// but WITHOUT ANY WARRANTY; without even the implied warranty of //
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20// GNU General Public License for more details: //
21// //
22// http://www.gnu.org/copyleft/gpl.html //
23// //
24///////////////////////////////////////////////////////////////////////////
25
26/**
27 * Unit tests for ../portfoliolib.php.
28 *
29 * @author nicolasconnault@gmail.com
30 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
31 * @package moodlecore
32 */
33
34if (!defined('MOODLE_INTERNAL')) {
35 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
36}
37
38require_once($CFG->libdir . '/portfoliolib.php');
39
fc2b6316 40class portfoliolibaddbutton_test extends UnitTestCaseUsingDatabase {
ef6f0f60 41
081a63a9 42 public static $includecoverage = array('lib/portfoliolib.php');
43
fc2b6316
SM
44 protected $testtables = array(
45 'lib' => array(
46 'portfolio_instance', 'portfolio_instance_user'));
47
48 public function setUp() {
49 parent::setUp();
50
51 $this->switch_to_test_db(); // Switch to test DB for all the execution
52
53 foreach ($this->testtables as $dir => $tables) {
54 $this->create_test_tables($tables, $dir); // Create tables
55 }
56
57 }
58
59 public function tearDown() {
60 parent::tearDown(); // In charge of droppng all the test tables
61 }
62
3dfe69c9
SM
63 /*
64 * TODO: The portfolio unit tests were obselete and did not work.
65 * They have been commented out so that they do not break the
66 * unit tests in Moodle 2.
67 *
68 * At some point:
69 * 1. These tests should be audited to see which ones were valuable.
70 * 2. The useful ones should be rewritten using the current standards
71 * for writing test cases.
72 *
73 * This might be left until Moodle 2.1 when the test case framework
74 * is due to change.
75 */
76 /*
77 * A test of setting and getting formats. What is returned in the getter is a combination of what is explicitly set in
78 * the button, and what is set in the static method of the export class.
79 *
80 * In some cases they conflict, in which case the button wins.
81 */
82
83 /*
ef6f0f60 84 function test_set_formats() {
c7d306e1 85
ef6f0f60 86 $button = new portfolio_add_button();
5fb29115 87 $button->set_callback_options('assignment_portfolio_caller', array('id' => 6), '/mod/assignment/locallib.php');
ef6f0f60 88 $formats = array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_IMAGE);
89 $button->set_formats($formats);
3dfe69c9
SM
90
91 // Expecting $formats + assignment_portfolio_caller::base_supported_formats merged to unique values.
92 $formats_combined = array_unique(array_merge($formats, assignment_portfolio_caller::base_supported_formats()));
93
94 // In this case, neither file or image conflict with leap2a, which is why all three are returned.
95 $this->assertEqual(count($formats_combined), count($button->get_formats()));
ef6f0f60 96 }
3dfe69c9 97 */
ef6f0f60 98}
99
8926f844 100