2 /** tests for includes/Html.php */
4 class HtmlTest
extends MediaWikiTestCase
{
5 private static $oldLang;
7 public function setUp() {
8 global $wgLang, $wgLanguageCode;
10 self
::$oldLang = $wgLang;
11 $wgLanguageCode = 'en';
12 $wgLang = Language
::factory( $wgLanguageCode );
15 public function tearDown() {
16 global $wgLang, $wgLanguageCode;
17 $wgLang = self
::$oldLang;
18 $wgLanguageCode = $wgLang->getCode();
21 public function testExpandAttributesSkipsNullAndFalse() {
25 Html
::expandAttributes( array( 'foo'=>null) ),
26 'skip keys with null value'
29 Html
::expandAttributes( array( 'foo'=>false) ),
30 'skip keys with false value'
32 $this->AssertNotEmpty(
33 Html
::expandAttributes( array( 'foo'=>'') ),
34 'keep keys with an empty string'
38 public function testExpandAttributesForBooleans() {
41 Html
::expandAttributes( array( 'selected'=>false) ),
42 'Boolean attributes do not generates output when value is false'
46 Html
::expandAttributes( array( 'selected'=>null) ),
47 'Boolean attributes do not generates output when value is null'
50 ### FIXME: maybe they should just output 'selected'
53 Html
::expandAttributes( array( 'selected'=>true ) ),
54 'Boolean attributes skip value output'
58 Html
::expandAttributes( array( 'selected' ) ),
59 'Boolean attributes (ex: selected) do not need a value'
64 * Test for Html::expandAttributes()
65 * Please note it output a string prefixed with a space!
67 public function testExpandAttributesVariousExpansions() {
71 Html
::expandAttributes( array( 'empty_string'=>'') ),
72 'Value with an empty string'
76 Html
::expandAttributes( array( 'key'=>'value') ),
81 Html
::expandAttributes( array( 'one'=>1) ),
82 'Value is a numeric one'
86 Html
::expandAttributes( array( 'zero'=>0) ),
87 'Value is a numeric zero'