X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FHtmlTest.php;h=e9349656bee268412d0e1a1eb34c26d573dec481;hb=96764fbc9a67fa6040c6123d31ac3746fc6fd98f;hp=4e010d42a3efb830063b0ad39dfee5e67a4688df;hpb=3222fabc4e7a9082181b39d32d641c3f0cdac5eb;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 4e010d42a3..e9349656be 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -37,11 +37,13 @@ class HtmlTest extends MediaWikiTestCase { 'wgLanguageCode' => $langCode, 'wgContLang' => $langObj, 'wgLang' => $langObj, - 'wgHtml5' => true, 'wgWellFormedXml' => false, ) ); } + /** + * @covers Html::element + */ public function testElementBasics() { $this->assertEquals( '', @@ -70,6 +72,35 @@ class HtmlTest extends MediaWikiTestCase { ); } + public function dataXmlMimeType() { + return array( + // ( $mimetype, $isXmlMimeType ) + # HTML is not an XML MimeType + array( 'text/html', false ), + # XML is an XML MimeType + array( 'text/xml', true ), + array( 'application/xml', true ), + # XHTML is an XML MimeType + array( 'application/xhtml+xml', true ), + # Make sure other +xml MimeTypes are supported + # SVG is another random MimeType even though we don't use it + array( 'image/svg+xml', true ), + # Complete random other MimeTypes are not XML + array( 'text/plain', false ), + ); + } + + /** + * @dataProvider dataXmlMimeType + * @covers Html::isXmlMimeType + */ + public function testXmlMimeType( $mimetype, $isXmlMimeType ) { + $this->assertEquals( $isXmlMimeType, Html::isXmlMimeType( $mimetype ) ); + } + + /** + * @covers HTML::expandAttributes + */ public function testExpandAttributesSkipsNullAndFalse() { ### EMPTY ######## @@ -87,6 +118,9 @@ class HtmlTest extends MediaWikiTestCase { ); } + /** + * @covers HTML::expandAttributes + */ public function testExpandAttributesForBooleans() { $this->assertEquals( '', @@ -117,19 +151,12 @@ class HtmlTest extends MediaWikiTestCase { Html::expandAttributes( array( 'selected' => true ) ), 'Boolean attributes have empty string value when value is true (wgWellFormedXml)' ); - - $this->setMwGlobals( 'wgHtml5', false ); - - $this->assertEquals( - ' selected="selected"', - Html::expandAttributes( array( 'selected' => true ) ), - 'Boolean attributes have their key as value when value is true (wgWellFormedXml, wgHTML5 = false)' - ); } /** * Test for Html::expandAttributes() * Please note it output a string prefixed with a space! + * @covers Html::expandAttributes */ public function testExpandAttributesVariousExpansions() { ### NOT EMPTY #### @@ -182,6 +209,7 @@ class HtmlTest extends MediaWikiTestCase { * Html::expandAttributes has special features for HTML * attributes that use space separated lists and also * allows arrays to be used as values. + * @covers Html::expandAttributes */ public function testExpandAttributesListValueAttributes() { ### STRING VALUES @@ -233,8 +261,9 @@ class HtmlTest extends MediaWikiTestCase { /** * Test feature added by r96188, let pass attributes values as * a PHP array. Restricted to class,rel, accesskey. + * @covers Html::expandAttributes */ - function testExpandAttributesSpaceSeparatedAttributesWithBoolean() { + public function testExpandAttributesSpaceSeparatedAttributesWithBoolean() { $this->assertEquals( ' class="booltrue one"', Html::expandAttributes( array( 'class' => array( @@ -257,8 +286,9 @@ class HtmlTest extends MediaWikiTestCase { * The later will take precedence. * * Feature added by r96188 + * @covers Html::expandAttributes */ - function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() { + public function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() { $this->assertEquals( ' class=""', Html::expandAttributes( array( 'class' => array( @@ -269,7 +299,10 @@ class HtmlTest extends MediaWikiTestCase { ); } - function testNamespaceSelector() { + /** + * @covers Html::namespaceSelector + */ + public function testNamespaceSelector() { $this->assertEquals( '' . "\n" . '' . "\n" . @@ -370,7 +403,7 @@ class HtmlTest extends MediaWikiTestCase { ); } - function testCanDisableANamespaces() { + public function testCanDisableANamespaces() { $this->assertEquals( '', Html::element( 'input', array( 'type' => $HTML5InputType ) ), @@ -441,7 +475,7 @@ class HtmlTest extends MediaWikiTestCase { * @covers Html::dropDefaults * @dataProvider provideElementsWithAttributesHavingDefaultValues */ - function testDropDefaults( $expected, $element, $attribs, $message = '' ) { + public function testDropDefaults( $expected, $element, $attribs, $message = '' ) { $this->assertEquals( $expected, Html::element( $element, $attribs ), $message ); } @@ -556,7 +590,8 @@ class HtmlTest extends MediaWikiTestCase { # see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx $cases[] = array( '', 'button', array( 'type' => 'submit' ), - 'According to standard the default type is "submit". Depending on compatibility mode IE might use "button", instead.', + 'According to standard the default type is "submit". ' + . 'Depending on compatibility mode IE might use "button", instead.', ); #