Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/simpletest/testhtmlwriter.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 
00027 if (!defined('MOODLE_INTERNAL')) {
00028     die('Direct access to this script is forbidden.');    
00029 }
00030 require_once($CFG->libdir . '/outputcomponents.php');
00031 
00032 
00039 class html_writer_test extends UnitTestCase {
00040 
00041     public static $includecoverage = array('lib/outputcomponents.php');
00042 
00043     public function test_start_tag() {
00044         $this->assertEqual('<div>', html_writer::start_tag('div'));
00045     }
00046 
00047     public function test_start_tag_with_attr() {
00048         $this->assertEqual('<div class="frog">',
00049                 html_writer::start_tag('div', array('class' => 'frog')));
00050     }
00051 
00052     public function test_start_tag_with_attrs() {
00053         $this->assertEqual('<div class="frog" id="mydiv">',
00054                 html_writer::start_tag('div', array('class' => 'frog', 'id' => 'mydiv')));
00055     }
00056 
00057     public function test_end_tag() {
00058         $this->assertEqual('</div>', html_writer::end_tag('div'));
00059     }
00060 
00061     public function test_empty_tag() {
00062         $this->assertEqual('<br />', html_writer::empty_tag('br'));
00063     }
00064 
00065     public function test_empty_tag_with_attrs() {
00066         $this->assertEqual('<input type="submit" value="frog" />',
00067                 html_writer::empty_tag('input', array('type' => 'submit', 'value' => 'frog')));
00068     }
00069 
00070     public function test_nonempty_tag_with_content() {
00071         $this->assertEqual('<div>Hello world!</div>',
00072                 html_writer::nonempty_tag('div', 'Hello world!'));
00073     }
00074 
00075     public function test_nonempty_tag_empty() {
00076         $this->assertEqual('',
00077                 html_writer::nonempty_tag('div', ''));
00078     }
00079 
00080     public function test_nonempty_tag_null() {
00081         $this->assertEqual('',
00082                 html_writer::nonempty_tag('div', null));
00083     }
00084 
00085     public function test_nonempty_tag_zero() {
00086         $this->assertEqual('<div class="score">0</div>',
00087                 html_writer::nonempty_tag('div', 0, array('class' => 'score')));
00088     }
00089 
00090     public function test_nonempty_tag_zero_string() {
00091         $this->assertEqual('<div class="score">0</div>',
00092                 html_writer::nonempty_tag('div', '0', array('class' => 'score')));
00093             }
00094 }
 All Data Structures Namespaces Files Functions Variables Enumerations