view = new Zend_View();
$this->helper = new Zend_View_Helper_FormPassword();
$this->helper->setView($this->view);
}
/**
* @group ZF-1666
*/
public function testCanDisableElement()
{
$html = $this->helper->formPassword(array(
'name' => 'foo',
'value' => 'bar',
'attribs' => array('disable' => true)
));
$this->assertRegexp('/]*?(disabled="disabled")/', $html);
}
/**
* @group ZF-1666
*/
public function testDisablingElementDoesNotRenderHiddenElements()
{
$html = $this->helper->formPassword(array(
'name' => 'foo',
'value' => 'bar',
'attribs' => array('disable' => true)
));
$this->assertNotRegexp('/]*?(type="hidden")/', $html);
}
public function testShouldRenderAsHtmlByDefault()
{
$test = $this->helper->formPassword('foo', 'bar');
$this->assertNotContains(' />', $test);
}
public function testShouldAllowRenderingAsXhtml()
{
$this->view->doctype('XHTML1_STRICT');
$test = $this->helper->formPassword('foo', 'bar');
$this->assertContains(' />', $test);
}
public function testShouldNotRenderValueByDefault()
{
$test = $this->helper->formPassword('foo', 'bar');
$this->assertNotContains('bar', $test);
}
/**
* @group ZF-2860
*/
public function testShouldRenderValueWhenRenderPasswordFlagPresentAndTrue()
{
$test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => true));
$this->assertContains('value="bar"', $test);
}
/**
* @group ZF-2860
*/
public function testRenderPasswordAttribShouldNeverBeRendered()
{
$test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => true));
$this->assertNotContains('renderPassword', $test);
$test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => false));
$this->assertNotContains('renderPassword', $test);
}
}
// Call Zend_View_Helper_FormPasswordTest::main() if this source file is executed directly.
if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormPasswordTest::main") {
Zend_View_Helper_FormPasswordTest::main();
}