From 9755d2e5aa51215e4d74a09ce7fbd39f24f8f702 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 30 Jan 2012 10:39:51 +0000 Subject: [PATCH] test Html::namespaceSelector() id & name attributes generation Method was introduced by r109990. --- tests/phpunit/includes/HtmlTest.php | 72 +++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 90ff763524..d3feaccb1c 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -257,4 +257,76 @@ class HtmlTest extends MediaWikiTestCase { 'Basic namespace selector with custom values' ); } + + function testNamespaceSelectorIdAndNameDefaultsAttributes() { + + $this->assertNsSelectorIdAndName( + 'namespace', 'namespace', + Html::namespaceSelector( array(), array( + # neither 'id' nor 'name' key given + )), + "Neither 'id' nor 'name' key given" + ); + + $this->assertNsSelectorIdAndName( + 'namespace', 'select_name', + Html::namespaceSelector( array(), array( + 'name' => 'select_name', + # no 'id' key given + )), + "No 'id' key given, 'name' given" + ); + + $this->assertNsSelectorIdAndName( + 'select_id', 'namespace', + Html::namespaceSelector( array(), array( + 'id' => 'select_id', + # no 'name' key given + )), + "'id' given, no 'name' key given" + ); + + $this->assertNsSelectorIdAndName( + 'select_id', 'select_name', + Html::namespaceSelector( array(), array( + 'id' => 'select_id', + 'name' => 'select_name', + )), + "Both 'id' and 'name' given" + ); + } + + /** + * Helper to verify id attribute value + * @param String $expectedName