element = new Zend_Form_Element_Radio('foo'); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @return void */ public function tearDown() { } public function getView() { require_once 'Zend/View.php'; $view = new Zend_View(); $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); return $view; } public function testRadioElementSubclassesMultiElement() { $this->assertTrue($this->element instanceof Zend_Form_Element_Multi); } public function testRadioElementSubclassesXhtmlElement() { $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); } public function testRadioElementInstanceOfBaseElement() { $this->assertTrue($this->element instanceof Zend_Form_Element); } public function testRadioElementIsNotAnArrayByDefault() { $this->assertFalse($this->element->isArray()); } public function testHelperAttributeSetToFormRadioByDefault() { $this->assertEquals('formRadio', $this->element->getAttrib('helper')); } public function testRadioElementUsesRadioHelperInViewHelperDecoratorByDefault() { $this->_checkZf2794(); $decorator = $this->element->getDecorator('viewHelper'); $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); $decorator->setElement($this->element); $helper = $decorator->getHelper(); $this->assertEquals('formRadio', $helper); } public function testCanDisableIndividualRadioOptions() { $this->element->setMultiOptions(array( 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz', 'bat' => 'Bat', 'test' => 'Test', )) ->setAttrib('disable', array('baz', 'test')); $html = $this->element->render($this->getView()); foreach (array('baz', 'test') as $test) { if (!preg_match('/(]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { $this->fail('Unable to find matching disabled option for ' . $test); } $this->assertRegexp('/]*?(disabled="disabled")/', $m[1]); } foreach (array('foo', 'bar', 'bat') as $test) { if (!preg_match('/(]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { $this->fail('Unable to find matching option for ' . $test); } $this->assertNotRegexp('/]*?(disabled="disabled")/', $m[1], var_export($m, 1)); } } public function testSpecifiedSeparatorIsUsedWhenRendering() { $this->element->setMultiOptions(array( 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz', 'bat' => 'Bat', 'test' => 'Test', )) ->setSeparator('--FooBarFunSep--'); $html = $this->element->render($this->getView()); $this->assertContains($this->element->getSeparator(), $html); $count = substr_count($html, $this->element->getSeparator()); $this->assertEquals(4, $count); } public function testRadioElementRendersDtDdWrapper() { $this->element->setMultiOptions(array( 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz', 'bat' => 'Bat', 'test' => 'Test', )); $html = $this->element->render($this->getView()); $this->assertRegexp('#