Index: trunk/phase3/tests/phpunit/includes/HtmlTest.php |
— | — | @@ -143,4 +143,43 @@ |
144 | 144 | 'Normalization should remove duplicates in string-lists in the array' |
145 | 145 | ); |
146 | 146 | } |
| 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 | + } |
147 | 186 | } |