HtmlTest.php 19.4 KB
Newer Older
Qiang Xue committed
1 2
<?php

3
namespace yiiunit\framework\helpers;
Qiang Xue committed
4 5 6

use Yii;
use yii\helpers\Html;
7
use yiiunit\TestCase;
Qiang Xue committed
8

9
class HtmlTest extends TestCase
Qiang Xue committed
10
{
Carsten Brandt committed
11
	protected function setUp()
Qiang Xue committed
12
	{
Carsten Brandt committed
13
		parent::setUp();
14
		$this->mockApplication(array(
Qiang Xue committed
15 16 17 18 19
			'components' => array(
				'request' => array(
					'class' => 'yii\web\Request',
					'url' => '/test',
				),
20 21 22
				'response' => array(
					'class' => 'yii\web\Response',
				),
Qiang Xue committed
23 24 25 26
			),
		));
	}

27 28 29 30 31 32 33 34
	public function assertEqualsWithoutLE($expected, $actual)
	{
		$expected = str_replace("\r\n", "\n", $expected);
		$actual = str_replace("\r\n", "\n", $actual);

		$this->assertEquals($expected, $actual);
	}

Qiang Xue committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
	public function testEncode()
	{
		$this->assertEquals("a&lt;&gt;&amp;&quot;&#039;", Html::encode("a<>&\"'"));
	}

	public function testDecode()
	{
		$this->assertEquals("a<>&\"'", Html::decode("a&lt;&gt;&amp;&quot;&#039;"));
	}

	public function testTag()
	{
		$this->assertEquals('<br>', Html::tag('br'));
		$this->assertEquals('<span></span>', Html::tag('span'));
		$this->assertEquals('<div>content</div>', Html::tag('div', 'content'));
		$this->assertEquals('<input type="text" name="test" value="&lt;&gt;">', Html::tag('input', '', array('type' => 'text', 'name' => 'test', 'value' => '<>')));
		$this->assertEquals('<span disabled></span>', Html::tag('span', '', array('disabled' => true)));
	}

	public function testBeginTag()
	{
		$this->assertEquals('<br>', Html::beginTag('br'));
		$this->assertEquals('<span id="test" class="title">', Html::beginTag('span', array('id' => 'test', 'class' => 'title')));
	}

	public function testEndTag()
	{
		$this->assertEquals('</br>', Html::endTag('br'));
		$this->assertEquals('</span>', Html::endTag('span'));
	}

	public function testStyle()
	{
		$content = 'a <>';
69 70
		$this->assertEquals("<style>$content</style>", Html::style($content));
		$this->assertEquals("<style type=\"text/less\">$content</style>", Html::style($content, array('type' => 'text/less')));
Qiang Xue committed
71 72 73 74 75
	}

	public function testScript()
	{
		$content = 'a <>';
76 77
		$this->assertEquals("<script>$content</script>", Html::script($content));
		$this->assertEquals("<script type=\"text/js\">$content</script>", Html::script($content, array('type' => 'text/js')));
Qiang Xue committed
78 79 80 81
	}

	public function testCssFile()
	{
82 83
		$this->assertEquals('<link href="http://example.com" rel="stylesheet">', Html::cssFile('http://example.com'));
		$this->assertEquals('<link href="/test" rel="stylesheet">', Html::cssFile(''));
Qiang Xue committed
84 85 86 87
	}

	public function testJsFile()
	{
88 89
		$this->assertEquals('<script src="http://example.com"></script>', Html::jsFile('http://example.com'));
		$this->assertEquals('<script src="/test"></script>', Html::jsFile(''));
Qiang Xue committed
90 91 92 93 94 95 96
	}

	public function testBeginForm()
	{
		$this->assertEquals('<form action="/test" method="post">', Html::beginForm());
		$this->assertEquals('<form action="/example" method="get">', Html::beginForm('/example', 'get'));
		$hiddens = array(
97 98
			'<input type="hidden" name="id" value="1">',
			'<input type="hidden" name="title" value="&lt;">',
Qiang Xue committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
		);
		$this->assertEquals('<form action="/example" method="get">' . "\n" . implode("\n", $hiddens), Html::beginForm('/example?id=1&title=%3C', 'get'));
	}

	public function testEndForm()
	{
		$this->assertEquals('</form>', Html::endForm());
	}

	public function testA()
	{
		$this->assertEquals('<a>something<></a>', Html::a('something<>'));
		$this->assertEquals('<a href="/example">something</a>', Html::a('something', '/example'));
		$this->assertEquals('<a href="/test">something</a>', Html::a('something', ''));
	}

	public function testMailto()
	{
		$this->assertEquals('<a href="mailto:test&lt;&gt;">test<></a>', Html::mailto('test<>'));
		$this->assertEquals('<a href="mailto:test&gt;">test<></a>', Html::mailto('test<>', 'test>'));
	}

	public function testImg()
	{
123 124 125
		$this->assertEquals('<img src="/example" alt="">', Html::img('/example'));
		$this->assertEquals('<img src="/test" alt="">', Html::img(''));
		$this->assertEquals('<img src="/example" width="10" alt="something">', Html::img('/example', array('alt' => 'something', 'width' => 10)));
Qiang Xue committed
126 127 128 129 130 131 132 133 134 135 136
	}

	public function testLabel()
	{
		$this->assertEquals('<label>something<></label>', Html::label('something<>'));
		$this->assertEquals('<label for="a">something<></label>', Html::label('something<>', 'a'));
		$this->assertEquals('<label class="test" for="a">something<></label>', Html::label('something<>', 'a', array('class' => 'test')));
	}

	public function testButton()
	{
137 138
		$this->assertEquals('<button>Button</button>', Html::button());
		$this->assertEquals('<button name="test" value="value">content<></button>', Html::button('content<>', array('name' => 'test', 'value' => 'value')));
Qiang Xue committed
139
		$this->assertEquals('<button type="submit" class="t" name="test" value="value">content<></button>', Html::button('content<>', array('type' => 'submit', 'name' => 'test', 'value' => 'value', 'class' => "t")));
Qiang Xue committed
140 141 142 143 144
	}

	public function testSubmitButton()
	{
		$this->assertEquals('<button type="submit">Submit</button>', Html::submitButton());
Qiang Xue committed
145
		$this->assertEquals('<button type="submit" class="t" name="test" value="value">content<></button>', Html::submitButton('content<>', array('name' => 'test', 'value' => 'value', 'class' => 't')));
Qiang Xue committed
146 147 148 149 150
	}

	public function testResetButton()
	{
		$this->assertEquals('<button type="reset">Reset</button>', Html::resetButton());
Qiang Xue committed
151
		$this->assertEquals('<button type="reset" class="t" name="test" value="value">content<></button>', Html::resetButton('content<>', array('name' => 'test', 'value' => 'value', 'class' => 't')));
Qiang Xue committed
152 153 154 155
	}

	public function testInput()
	{
156 157
		$this->assertEquals('<input type="text">', Html::input('text'));
		$this->assertEquals('<input type="text" class="t" name="test" value="value">', Html::input('text', 'test', 'value', array('class' => 't')));
Qiang Xue committed
158 159 160 161
	}

	public function testButtonInput()
	{
162 163
		$this->assertEquals('<input type="button" value="Button">', Html::buttonInput());
		$this->assertEquals('<input type="button" class="a" name="test" value="text">', Html::buttonInput('text', array('name' => 'test', 'class' => 'a')));
Qiang Xue committed
164 165 166 167
	}

	public function testSubmitInput()
	{
168 169
		$this->assertEquals('<input type="submit" value="Submit">', Html::submitInput());
		$this->assertEquals('<input type="submit" class="a" name="test" value="text">', Html::submitInput('text', array('name' => 'test', 'class' => 'a')));
Qiang Xue committed
170 171 172 173
	}

	public function testResetInput()
	{
174 175
		$this->assertEquals('<input type="reset" value="Reset">', Html::resetInput());
		$this->assertEquals('<input type="reset" class="a" name="test" value="text">', Html::resetInput('text', array('name' => 'test', 'class' => 'a')));
Qiang Xue committed
176 177 178 179
	}

	public function testTextInput()
	{
180 181
		$this->assertEquals('<input type="text" name="test">', Html::textInput('test'));
		$this->assertEquals('<input type="text" class="t" name="test" value="value">', Html::textInput('test', 'value', array('class' => 't')));
Qiang Xue committed
182 183 184 185
	}

	public function testHiddenInput()
	{
186 187
		$this->assertEquals('<input type="hidden" name="test">', Html::hiddenInput('test'));
		$this->assertEquals('<input type="hidden" class="t" name="test" value="value">', Html::hiddenInput('test', 'value', array('class' => 't')));
Qiang Xue committed
188 189 190 191
	}

	public function testPasswordInput()
	{
192 193
		$this->assertEquals('<input type="password" name="test">', Html::passwordInput('test'));
		$this->assertEquals('<input type="password" class="t" name="test" value="value">', Html::passwordInput('test', 'value', array('class' => 't')));
Qiang Xue committed
194 195 196 197
	}

	public function testFileInput()
	{
198 199
		$this->assertEquals('<input type="file" name="test">', Html::fileInput('test'));
		$this->assertEquals('<input type="file" class="t" name="test" value="value">', Html::fileInput('test', 'value', array('class' => 't')));
Qiang Xue committed
200 201 202 203 204 205 206 207 208 209
	}

	public function testTextarea()
	{
		$this->assertEquals('<textarea name="test"></textarea>', Html::textarea('test'));
		$this->assertEquals('<textarea class="t" name="test">value&lt;&gt;</textarea>', Html::textarea('test', 'value<>', array('class' => 't')));
	}

	public function testRadio()
	{
210 211 212
		$this->assertEquals('<input type="radio" name="test" value="1">', Html::radio('test'));
		$this->assertEquals('<input type="radio" class="a" name="test" checked>', Html::radio('test', true, array('class' => 'a', 'value' => null)));
		$this->assertEquals('<input type="hidden" name="test" value="0"><input type="radio" class="a" name="test" value="2" checked>', Html::radio('test', true, array('class' => 'a' , 'uncheck' => '0', 'value' => 2)));
Qiang Xue committed
213

Qiang Xue committed
214
		$this->assertEquals('<div class="radio"><label class="bbb"><input type="radio" class="a" name="test" checked> ccc</label></div>', Html::radio('test', true, array(
Qiang Xue committed
215 216 217 218 219
			'class' => 'a',
			'value' => null,
			'label' => 'ccc',
			'labelOptions' => array('class' =>'bbb'),
		)));
Qiang Xue committed
220
		$this->assertEquals('<input type="hidden" name="test" value="0"><div class="radio"><label><input type="radio" class="a" name="test" value="2" checked> ccc</label></div>', Html::radio('test', true, array(
Qiang Xue committed
221 222 223 224 225
			'class' => 'a',
			'uncheck' => '0',
			'label' => 'ccc',
			'value' => 2,
		)));
Qiang Xue committed
226 227 228 229
	}

	public function testCheckbox()
	{
230 231 232
		$this->assertEquals('<input type="checkbox" name="test" value="1">', Html::checkbox('test'));
		$this->assertEquals('<input type="checkbox" class="a" name="test" checked>', Html::checkbox('test', true, array('class' => 'a', 'value' => null)));
		$this->assertEquals('<input type="hidden" name="test" value="0"><input type="checkbox" class="a" name="test" value="2" checked>', Html::checkbox('test', true, array('class' => 'a', 'uncheck' => '0', 'value' => 2)));
Qiang Xue committed
233 234 235 236 237 238 239

		$this->assertEquals('<div class="checkbox"><label class="bbb"><input type="checkbox" class="a" name="test" checked> ccc</label></div>', Html::checkbox('test', true, array(
			'class' => 'a',
			'value' => null,
			'label' => 'ccc',
			'labelOptions' => array('class' =>'bbb'),
		)));
Qiang Xue committed
240
		$this->assertEquals('<input type="hidden" name="test" value="0"><div class="checkbox"><label><input type="checkbox" class="a" name="test" value="2" checked> ccc</label></div>', Html::checkbox('test', true, array(
Qiang Xue committed
241 242 243 244 245
			'class' => 'a',
			'uncheck' => '0',
			'label' => 'ccc',
			'value' => 2,
		)));
Qiang Xue committed
246 247 248 249 250 251 252 253 254
	}

	public function testDropDownList()
	{
		$expected = <<<EOD
<select name="test">

</select>
EOD;
255
		$this->assertEqualsWithoutLE($expected, Html::dropDownList('test'));
Qiang Xue committed
256 257 258 259 260 261
		$expected = <<<EOD
<select name="test">
<option value="value1">text1</option>
<option value="value2">text2</option>
</select>
EOD;
262
		$this->assertEqualsWithoutLE($expected, Html::dropDownList('test', null, $this->getDataItems()));
Qiang Xue committed
263 264 265
		$expected = <<<EOD
<select name="test">
<option value="value1">text1</option>
266
<option value="value2" selected>text2</option>
Qiang Xue committed
267 268
</select>
EOD;
269
		$this->assertEqualsWithoutLE($expected, Html::dropDownList('test', 'value2', $this->getDataItems()));
Qiang Xue committed
270 271 272 273 274 275 276 277 278
	}

	public function testListBox()
	{
		$expected = <<<EOD
<select name="test" size="4">

</select>
EOD;
279
		$this->assertEqualsWithoutLE($expected, Html::listBox('test'));
Qiang Xue committed
280 281 282 283 284 285
		$expected = <<<EOD
<select name="test" size="5">
<option value="value1">text1</option>
<option value="value2">text2</option>
</select>
EOD;
286
		$this->assertEqualsWithoutLE($expected, Html::listBox('test', null, $this->getDataItems(), array('size' => 5)));
Qiang Xue committed
287 288 289 290 291 292
		$expected = <<<EOD
<select name="test" size="4">
<option value="value1&lt;&gt;">text1&lt;&gt;</option>
<option value="value  2">text&nbsp;&nbsp;2</option>
</select>
EOD;
293
		$this->assertEqualsWithoutLE($expected, Html::listBox('test', null, $this->getDataItems2()));
Qiang Xue committed
294 295 296
		$expected = <<<EOD
<select name="test" size="4">
<option value="value1">text1</option>
297
<option value="value2" selected>text2</option>
Qiang Xue committed
298 299
</select>
EOD;
300
		$this->assertEqualsWithoutLE($expected, Html::listBox('test', 'value2', $this->getDataItems()));
Qiang Xue committed
301 302
		$expected = <<<EOD
<select name="test" size="4">
303 304
<option value="value1" selected>text1</option>
<option value="value2" selected>text2</option>
Qiang Xue committed
305 306
</select>
EOD;
307
		$this->assertEqualsWithoutLE($expected, Html::listBox('test', array('value1', 'value2'), $this->getDataItems()));
Qiang Xue committed
308 309

		$expected = <<<EOD
310
<select name="test[]" multiple size="4">
Qiang Xue committed
311 312 313

</select>
EOD;
314
		$this->assertEqualsWithoutLE($expected, Html::listBox('test', null, array(), array('multiple' => true)));
Qiang Xue committed
315
		$expected = <<<EOD
316
<input type="hidden" name="test" value="0"><select name="test" size="4">
Qiang Xue committed
317 318 319

</select>
EOD;
320
		$this->assertEqualsWithoutLE($expected, Html::listBox('test', '', array(), array('unselect' => '0')));
Qiang Xue committed
321 322 323 324 325 326 327
	}

	public function testCheckboxList()
	{
		$this->assertEquals('', Html::checkboxList('test'));

		$expected = <<<EOD
Qiang Xue committed
328 329
<div class="checkbox"><label><input type="checkbox" name="test[]" value="value1"> text1</label></div>
<div class="checkbox"><label><input type="checkbox" name="test[]" value="value2" checked> text2</label></div>
Qiang Xue committed
330
EOD;
331
		$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', array('value2'), $this->getDataItems()));
Qiang Xue committed
332 333

		$expected = <<<EOD
Qiang Xue committed
334 335
<div class="checkbox"><label><input type="checkbox" name="test[]" value="value1&lt;&gt;"> text1&lt;&gt;</label></div>
<div class="checkbox"><label><input type="checkbox" name="test[]" value="value  2"> text  2</label></div>
Qiang Xue committed
336
EOD;
337
		$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', array('value2'), $this->getDataItems2()));
Qiang Xue committed
338 339

		$expected = <<<EOD
Qiang Xue committed
340
<input type="hidden" name="test" value="0"><div class="checkbox"><label><input type="checkbox" name="test[]" value="value1"> text1</label></div><br>
Qiang Xue committed
341
<div class="checkbox"><label><input type="checkbox" name="test[]" value="value2" checked> text2</label></div>
Qiang Xue committed
342
EOD;
343
		$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', array('value2'), $this->getDataItems(), array(
344
			'separator' => "<br>\n",
Qiang Xue committed
345 346 347 348
			'unselect' => '0',
		)));

		$expected = <<<EOD
349 350
0<label>text1 <input type="checkbox" name="test[]" value="value1"></label>
1<label>text2 <input type="checkbox" name="test[]" value="value2" checked></label>
Qiang Xue committed
351
EOD;
352
		$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', array('value2'), $this->getDataItems(), array(
Qiang Xue committed
353
			'item' => function ($index, $label, $name, $checked, $value) {
354
				return $index . Html::label($label . ' ' . Html::checkbox($name, $checked, array('value' => $value)));
Qiang Xue committed
355 356 357 358 359 360 361 362 363
			}
		)));
	}

	public function testRadioList()
	{
		$this->assertEquals('', Html::radioList('test'));

		$expected = <<<EOD
Qiang Xue committed
364 365
<div class="radio"><label><input type="radio" name="test" value="value1"> text1</label></div>
<div class="radio"><label><input type="radio" name="test" value="value2" checked> text2</label></div>
Qiang Xue committed
366
EOD;
367
		$this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems()));
Qiang Xue committed
368 369

		$expected = <<<EOD
Qiang Xue committed
370 371
<div class="radio"><label><input type="radio" name="test" value="value1&lt;&gt;"> text1&lt;&gt;</label></div>
<div class="radio"><label><input type="radio" name="test" value="value  2"> text  2</label></div>
Qiang Xue committed
372
EOD;
Alexander Makarov committed
373
		$this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems2()));
Qiang Xue committed
374 375

		$expected = <<<EOD
Qiang Xue committed
376
<input type="hidden" name="test" value="0"><div class="radio"><label><input type="radio" name="test" value="value1"> text1</label></div><br>
Qiang Xue committed
377
<div class="radio"><label><input type="radio" name="test" value="value2" checked> text2</label></div>
Qiang Xue committed
378
EOD;
379
		$this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems(), array(
380
			'separator' => "<br>\n",
Qiang Xue committed
381 382 383 384
			'unselect' => '0',
		)));

		$expected = <<<EOD
385 386
0<label>text1 <input type="radio" name="test" value="value1"></label>
1<label>text2 <input type="radio" name="test" value="value2" checked></label>
Qiang Xue committed
387
EOD;
388
		$this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems(), array(
Qiang Xue committed
389
			'item' => function ($index, $label, $name, $checked, $value) {
390
				return $index . Html::label($label . ' ' . Html::radio($name, $checked, array('value' => $value)));
Qiang Xue committed
391 392 393 394
			}
		)));
	}

395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
	public function testUl()
	{
		$data = array(
			1, 'abc', '<>',
		);
		$expected = <<<EOD
<ul>
<li>1</li>
<li>abc</li>
<li>&lt;&gt;</li>
</ul>
EOD;
		$this->assertEqualsWithoutLE($expected, Html::ul($data));
		$expected = <<<EOD
<ul class="test">
<li class="item-0">1</li>
<li class="item-1">abc</li>
<li class="item-2"><></li>
</ul>
EOD;
		$this->assertEqualsWithoutLE($expected, Html::ul($data, array(
			'class' => 'test',
Alexander Makarov committed
417
			'item' => function ($item, $index) {
418 419 420 421 422 423 424 425 426 427 428 429
				return "<li class=\"item-$index\">$item</li>";
			}
		)));
	}

	public function testOl()
	{
		$data = array(
			1, 'abc', '<>',
		);
		$expected = <<<EOD
<ol>
430 431 432
<li class="ti">1</li>
<li class="ti">abc</li>
<li class="ti">&lt;&gt;</li>
433 434
</ol>
EOD;
435 436 437
		$this->assertEqualsWithoutLE($expected, Html::ol($data, array(
			'itemOptions' => array('class' => 'ti'),
		)));
438 439 440 441 442 443 444 445 446
		$expected = <<<EOD
<ol class="test">
<li class="item-0">1</li>
<li class="item-1">abc</li>
<li class="item-2"><></li>
</ol>
EOD;
		$this->assertEqualsWithoutLE($expected, Html::ol($data, array(
			'class' => 'test',
Alexander Makarov committed
447
			'item' => function ($item, $index) {
448 449 450 451 452
				return "<li class=\"item-$index\">$item</li>";
			}
		)));
	}

Qiang Xue committed
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
	public function testRenderOptions()
	{
		$data = array(
			'value1' => 'label1',
			'group1' => array(
				'value11' => 'label11',
				'group11' => array(
					'value111' => 'label111',
				),
				'group12' => array(),
			),
			'value2' => 'label2',
			'group2' => array(),
		);
		$expected = <<<EOD
<option value="">please&nbsp;select&lt;&gt;</option>
469
<option value="value1" selected>label1</option>
Qiang Xue committed
470 471 472
<optgroup label="group1">
<option value="value11">label11</option>
<optgroup label="group11">
473
<option class="option" value="value111" selected>label111</option>
Qiang Xue committed
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
</optgroup>
<optgroup class="group" label="group12">

</optgroup>
</optgroup>
<option value="value2">label2</option>
<optgroup label="group2">

</optgroup>
EOD;
		$attributes = array(
			'prompt' => 'please select<>',
			'options' => array(
				'value111' => array('class' => 'option'),
			),
			'groups' => array(
				'group12' => array('class' => 'group'),
			),
		);
493
		$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions(array('value111', 'value1'), $data, $attributes));
Qiang Xue committed
494 495 496 497 498 499
	}

	public function testRenderAttributes()
	{
		$this->assertEquals('', Html::renderTagAttributes(array()));
		$this->assertEquals(' name="test" value="1&lt;&gt;"', Html::renderTagAttributes(array('name' => 'test', 'empty' => null, 'value' => '1<>')));
500
		$this->assertEquals(' checked disabled', Html::renderTagAttributes(array('checked' => true, 'disabled' => true, 'hidden' => false)));
Qiang Xue committed
501 502
	}

503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
	public function testAddCssClass()
	{
		$options = array();
		Html::addCssClass($options, 'test');
		$this->assertEquals(array('class' => 'test'), $options);
		Html::addCssClass($options, 'test');
		$this->assertEquals(array('class' => 'test'), $options);
		Html::addCssClass($options, 'test2');
		$this->assertEquals(array('class' => 'test test2'), $options);
		Html::addCssClass($options, 'test');
		$this->assertEquals(array('class' => 'test test2'), $options);
		Html::addCssClass($options, 'test2');
		$this->assertEquals(array('class' => 'test test2'), $options);
		Html::addCssClass($options, 'test3');
		$this->assertEquals(array('class' => 'test test2 test3'), $options);
		Html::addCssClass($options, 'test2');
		$this->assertEquals(array('class' => 'test test2 test3'), $options);
	}

	public function testRemoveCssClass()
	{
		$options = array('class' => 'test test2 test3');
		Html::removeCssClass($options, 'test2');
		$this->assertEquals(array('class' => 'test test3'), $options);
		Html::removeCssClass($options, 'test2');
		$this->assertEquals(array('class' => 'test test3'), $options);
		Html::removeCssClass($options, 'test');
		$this->assertEquals(array('class' => 'test3'), $options);
		Html::removeCssClass($options, 'test3');
		$this->assertEquals(array(), $options);
	}

Qiang Xue committed
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
	protected function getDataItems()
	{
		return array(
			'value1' => 'text1',
			'value2' => 'text2',
		);
	}

	protected function getDataItems2()
	{
		return array(
			'value1<>' => 'text1<>',
			'value  2' => 'text  2',
		);
	}
}