Пример #1
0
 function testSetAttr()
 {
     $t = new Tag('b', 'hello', 'one');
     $this->assertEquals('<b class="one">hello</b>', $t->toHTML(), 'Установлен class');
     $t->setAttr(false);
     $this->assertEquals('<b>hello</b>', $t->toHTML(), 'Атрибуты стерты');
     $t->setAttr(array('style' => 'width: 100px;'));
     $this->assertEquals('<b style="width: 100px;">hello</b>', $t->toHTML(), 'Установлен style');
     $t->setAttr('two');
     $this->assertEquals('<b class="two">hello</b>', $t->toHTML(), 'Установлен class=two');
     $t = new Tag('input', '123', array('type' => 'text'), true);
     $t->setId('one');
     $t->setClass('two');
     $t->setName('one[two]');
     $t->setStyle('width: 100px;');
     $this->assertEquals('<input class="two" id="one" name="one[two]" style="width: 100px;" type="text" value="123" />', $t->toHTML(), 'Типовые атрибуты заданы через сеттеры');
 }