2013-08-06 10:50:52 +02:00
|
|
|
<?php
|
2014-04-10 10:32:50 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-08-06 10:50:52 +02:00
|
|
|
|
|
|
|
namespace Tests\Icinga\Web;
|
|
|
|
|
|
|
|
use Icinga\Web\Form;
|
2014-04-10 10:32:50 +02:00
|
|
|
use Icinga\Test\BaseTestCase;
|
2013-08-06 10:50:52 +02:00
|
|
|
|
2014-04-10 10:32:50 +02:00
|
|
|
class FormTest extends BaseTestCase
|
2013-08-06 10:50:52 +02:00
|
|
|
{
|
2014-04-24 10:13:47 +02:00
|
|
|
public function testWhetherAddElementDoesNotAddSpecificDecorators()
|
2013-08-06 10:50:52 +02:00
|
|
|
{
|
2014-04-24 10:13:47 +02:00
|
|
|
$form = new Form();
|
|
|
|
$form->addElement('text', 'someText');
|
|
|
|
$element = $form->getElement('someText');
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
$element->getDecorator('HtmlTag'),
|
|
|
|
'Form::addElement does not remove the HtmlTag-Decorator'
|
|
|
|
);
|
|
|
|
$this->assertFalse(
|
|
|
|
$element->getDecorator('Label'),
|
|
|
|
'Form::addElement does not remove the Label-Decorator'
|
|
|
|
);
|
|
|
|
$this->assertFalse(
|
|
|
|
$element->getDecorator('DtDdWrapper'),
|
|
|
|
'Form::addElement does not remove the DtDdWrapper-Decorator'
|
|
|
|
);
|
2013-08-06 10:50:52 +02:00
|
|
|
}
|
|
|
|
|
2014-04-24 10:13:47 +02:00
|
|
|
public function testWhetherAddElementDoesNotAddAnyOptionalDecoratorsToHiddenElements()
|
2013-08-06 10:50:52 +02:00
|
|
|
{
|
2014-04-24 10:13:47 +02:00
|
|
|
$form = new Form();
|
|
|
|
$form->addElement('hidden', 'somethingHidden');
|
|
|
|
$element = $form->getElement('somethingHidden');
|
|
|
|
|
|
|
|
$this->assertCount(
|
|
|
|
1,
|
|
|
|
$element->getDecorators(),
|
|
|
|
'Form::addElement adds more decorators than necessary to hidden elements'
|
|
|
|
);
|
|
|
|
$this->assertInstanceOf(
|
|
|
|
'\Zend_Form_Decorator_ViewHelper',
|
|
|
|
$element->getDecorator('ViewHelper'),
|
|
|
|
'Form::addElement does not add the ViewHelper-Decorator to hidden elements'
|
|
|
|
);
|
2013-08-06 10:50:52 +02:00
|
|
|
}
|
|
|
|
|
2014-04-24 10:13:47 +02:00
|
|
|
public function testWhetherLoadDefaultDecoratorsDoesNotAddTheHtmlTagDecorator()
|
2013-08-06 10:50:52 +02:00
|
|
|
{
|
2014-04-24 10:13:47 +02:00
|
|
|
$form = new Form();
|
|
|
|
$form->loadDefaultDecorators();
|
|
|
|
|
|
|
|
$this->assertArrayNotHasKey(
|
|
|
|
'HtmlTag',
|
|
|
|
$form->getDecorators(),
|
|
|
|
'Form::loadDefaultDecorators adds the HtmlTag-Decorator'
|
|
|
|
);
|
2013-08-06 10:50:52 +02:00
|
|
|
}
|
2013-09-04 18:28:35 +02:00
|
|
|
}
|