Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/simpletest/testportfolioaddbutton.php
Go to the documentation of this file.
00001 <?php
00002 
00004 //                                                                       //
00005 // NOTICE OF COPYRIGHT                                                   //
00006 //                                                                       //
00007 // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
00008 //          http://moodle.org                                            //
00009 //                                                                       //
00010 // Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
00011 //                                                                       //
00012 // This program is free software; you can redistribute it and/or modify  //
00013 // it under the terms of the GNU General Public License as published by  //
00014 // the Free Software Foundation; either version 2 of the License, or     //
00015 // (at your option) any later version.                                   //
00016 //                                                                       //
00017 // This program is distributed in the hope that it will be useful,       //
00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
00020 // GNU General Public License for more details:                          //
00021 //                                                                       //
00022 //          http://www.gnu.org/copyleft/gpl.html                         //
00023 //                                                                       //
00025 
00034 if (!defined('MOODLE_INTERNAL')) {
00035     die('Direct access to this script is forbidden.');    
00036 }
00037 
00038 require_once($CFG->libdir . '/portfoliolib.php');
00039 
00040 class portfoliolibaddbutton_test extends UnitTestCaseUsingDatabase {
00041 
00042     public static $includecoverage = array('lib/portfoliolib.php');
00043 
00044     protected $testtables = array(
00045                 'lib' => array(
00046                     'portfolio_instance', 'portfolio_instance_user'));
00047     
00048     public function setUp() {
00049         parent::setUp();
00050 
00051         $this->switch_to_test_db(); // Switch to test DB for all the execution
00052 
00053         foreach ($this->testtables as $dir => $tables) {
00054             $this->create_test_tables($tables, $dir); // Create tables
00055         }
00056 
00057     }
00058 
00059     public function tearDown() {
00060         parent::tearDown(); // In charge of droppng all the test tables
00061     }
00062 
00063     /*
00064      * TODO: The portfolio unit tests were obselete and did not work.
00065      * They have been commented out so that they do not break the
00066      * unit tests in Moodle 2.
00067      *
00068      * At some point:
00069      * 1. These tests should be audited to see which ones were valuable.
00070      * 2. The useful ones should be rewritten using the current standards
00071      *    for writing test cases.
00072      *
00073      * This might be left until Moodle 2.1 when the test case framework
00074      * is due to change.
00075      */
00076     /*
00077      * A test of setting and getting formats. What is returned in the getter is a combination of what is explicitly set in 
00078      * the button, and what is set in the static method of the export class.
00079      * 
00080      * In some cases they conflict, in which case the button wins. 
00081      */
00082 
00083     /*
00084     function test_set_formats() {
00085 
00086         $button = new portfolio_add_button();
00087         $button->set_callback_options('assignment_portfolio_caller', array('id' => 6), '/mod/assignment/locallib.php');
00088         $formats = array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_IMAGE);
00089         $button->set_formats($formats);
00090  
00091         // Expecting $formats + assignment_portfolio_caller::base_supported_formats merged to unique values.
00092         $formats_combined = array_unique(array_merge($formats, assignment_portfolio_caller::base_supported_formats()));
00093         
00094         // In this case, neither file or image conflict with leap2a, which is why all three are returned.
00095         $this->assertEqual(count($formats_combined), count($button->get_formats()));
00096     }
00097     */
00098 }
00099 
00100 
 All Data Structures Namespaces Files Functions Variables Enumerations