2
// Call Zend_View_Helper_FormTextTest::main() if this source file is executed directly.
3
if (!defined("PHPUnit_MAIN_METHOD")) {
4
define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormTextTest::main");
7
require_once dirname(__FILE__) . '/../../../TestHelper.php';
9
require_once 'Zend/View.php';
10
require_once 'Zend/View/Helper/FormText.php';
11
require_once 'Zend/Registry.php';
14
* Zend_View_Helper_FormTextTest
16
* Tests formText helper, including some common functionality of all form helpers
18
* @uses PHPUnit_Framework_TestCase
19
* @version $Id: FormTextTest.php 11973 2008-10-15 16:00:56Z matthew $
21
class Zend_View_Helper_FormTextTest extends PHPUnit_Framework_TestCase
24
* Runs the test methods of this class.
29
public static function main()
31
$suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormTextTest");
32
$result = PHPUnit_TextUI_TestRunner::run($suite);
36
* Sets up the fixture, for example, open a network connection.
37
* This method is called before a test is executed.
41
protected function setUp()
43
if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) {
44
$registry = Zend_Registry::getInstance();
45
unset($registry['Zend_View_Helper_Doctype']);
47
$this->view = new Zend_View();
48
$this->helper = new Zend_View_Helper_FormText();
49
$this->helper->setView($this->view);
52
public function testIdSetFromName()
54
$element = $this->helper->formText('foo');
55
$this->assertContains('name="foo"', $element);
56
$this->assertContains('id="foo"', $element);
59
public function testSetIdFromAttribs()
61
$element = $this->helper->formText('foo', null, array('id' => 'bar'));
62
$this->assertContains('name="foo"', $element);
63
$this->assertContains('id="bar"', $element);
66
public function testSetValue()
68
$element = $this->helper->formText('foo', 'bar');
69
$this->assertContains('name="foo"', $element);
70
$this->assertContains('value="bar"', $element);
73
public function testReadOnlyAttribute()
75
$element = $this->helper->formText('foo', null, array('readonly' => 'readonly'));
76
$this->assertContains('readonly="readonly"', $element);
82
public function testCanDisableElement()
84
$html = $this->helper->formText(array(
87
'attribs' => array('disable' => true)
90
$this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html);
96
public function testDisablingElementDoesNotRenderHiddenElements()
98
$html = $this->helper->formText(array(
101
'attribs' => array('disable' => true)
104
$this->assertNotRegexp('/<input[^>]*?(type="hidden")/', $html);
107
public function testRendersAsHtmlByDefault()
109
$test = $this->helper->formText('foo', 'bar');
110
$this->assertNotContains(' />', $test);
113
public function testCanRendersAsXHtml()
115
$this->view->doctype('XHTML1_STRICT');
116
$test = $this->helper->formText('foo', 'bar');
117
$this->assertContains(' />', $test);
121
// Call Zend_View_Helper_FormTextTest::main() if this source file is executed directly.
122
if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormTextTest::main") {
123
Zend_View_Helper_FormTextTest::main();