r100629 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100628‎ | r100629 | r100630 >
Date:17:45, 24 October 2011
Author:hashar
Status:ok (Comments)
Tags:
Comment:
Tests for r96188 features

That revision let us pass an array of values to 'class', 'rel'
and 'accesskey'. The revision requested some tests :)
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/HtmlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/HtmlTest.php
@@ -143,4 +143,43 @@
144144 'Normalization should remove duplicates in string-lists in the array'
145145 );
146146 }
 147+
 148+ /**
 149+ * Test feature added by r96188, let pass attributes values as
 150+ * a PHP array. Restricted to class,rel, accesskey.
 151+ */
 152+ function testExpandAttributesSpaceSeparatedAttributesWithBoolean() {
 153+ $this->assertEquals(
 154+ ' class="booltrue one"',
 155+ Html::expandAttributes( array( 'class' => array(
 156+ 'booltrue' => true,
 157+ 'one' => 1,
 158+
 159+ # Method use isset() internally, make sure we do discard
 160+ # attributes values which have been assigned well known values
 161+ 'emptystring' => '',
 162+ 'boolfalse' => false,
 163+ 'zero' => 0,
 164+ 'null' => null,
 165+ )))
 166+ );
 167+ }
 168+
 169+ /**
 170+ * How do we handle duplicate keys in HTML attributes expansion?
 171+ * We could pass a "class" the values: 'GREEN' and array( 'GREEN' => false )
 172+ * The later will take precedence.
 173+ *
 174+ * Feature added by r96188
 175+ */
 176+ function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
 177+ $this->assertEquals(
 178+ ' class=""',
 179+ HTML::expandAttributes( array( 'class' => array(
 180+ 'GREEN',
 181+ 'GREEN' => false,
 182+ 'GREEN',
 183+ )))
 184+ );
 185+ }
147186 }

Sign-offs

UserFlagDate
Dantmaninspected10:15, 25 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96188Expand r96170's support for space separated attributes with support for boole...dantman14:36, 3 September 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:25, 25 October 2011

The subarrays look icky and overtly complex. Why not just make it a list instead of array? Spaces in line # attributes ...

#Comment by Dantman (talk | contribs)   10:17, 25 October 2011

You commenting on a feature on it's test commit? Look at the commit summary for r96188 and the comments.

Status & tagging log