Xml::label() tests. Follow up r63675.
authorAntoine Musso <hashar@users.mediawiki.org>
Sun, 7 Nov 2010 10:06:22 +0000 (10:06 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sun, 7 Nov 2010 10:06:22 +0000 (10:06 +0000)
maintenance/tests/phpunit/includes/XmlTest.php

index 27be6ba..7298f9f 100644 (file)
@@ -92,6 +92,39 @@ class XmlTest extends PHPUnit_Framework_TestCase {
                );
        }
 
+       #
+       # input and label
+       #
+       function testLabelCreation() {
+               $this->assertEquals(
+                       '<label for="id">name</label>',
+                       Xml::label( 'name', 'id' ),
+                       'label() with no attribs'
+               );
+       }
+       function testLabelAttributeCanOnlyBeClass() {
+               $this->assertEquals(
+                       '<label for="id">name</label>',
+                       Xml::label( 'name', 'id', array( 'generated' => true ) ),
+                       'label() can not be given a generated attribute'
+               );
+               $this->assertEquals(
+                       '<label for="id" class="nice">name</label>',
+                       Xml::label( 'name', 'id', array( 'class' => 'nice' ) ),
+                       'label() can get a class attribute'
+               );
+               $this->assertEquals(
+                       '<label for="id" class="nice">name</label>',
+                       Xml::label( 'name', 'id', array( 
+                               'generated' => true,
+                               'class' => 'nice',
+                               'anotherattr' => 'value',
+                               )
+                       ),
+                       'label() skip all attributes but "class"'
+               );
+       }
+
        #
        # JS
        #