public function testAddClass() { $htmlElement = new \Fiv\Form\Element\Html(); $currentClassName = $htmlElement->getAttribute('class'); $this->assertEmpty($currentClassName); $htmlElement->addClass('test'); $this->assertEquals('test', $htmlElement->getAttribute('class')); $htmlElement->setAttribute('class', ''); $this->assertEmpty($htmlElement->getAttribute('class')); $htmlElement->setAttribute('class', 'custom_class'); $this->assertEquals("custom_class", $htmlElement->getAttribute('class')); $htmlElement->addClass('other_class'); $this->assertEquals('custom_class other_class', $htmlElement->getAttribute('class')); }
/** * @inheritdoc */ public function setAttribute($name, $value) { if ($name === 'value') { # apply filters to the value $filters = $this->getFilters(); foreach ($filters as $filter) { $value = $filter->apply($value); } $this->value = $value; } return parent::setAttribute($name, $value); }