silverstripe-framework/tests/forms/ConfirmedPasswordFieldTest.php
Sam Minnee 1f7fc1f76a FIX Remove instances of lines longer than 120c
The entire framework repo (with the exception of system-generated files) has been amended to respect the 120c line-length limit.  This is in preparation for the enforcement of this rule with PHP_CodeSniffer.
2012-09-30 17:18:13 +13:00

36 lines
1.6 KiB
PHP

<?php
/**
* @package framework
* @subpackage tests
*/
class ConfirmedPasswordFieldTest extends SapphireTest {
public function testSetValue() {
$field = new ConfirmedPasswordField('Test', 'Testing', 'valueA');
$this->assertEquals('valueA', $field->Value());
$this->assertEquals('valueA', $field->children->fieldByName($field->getName() . '[_Password]')->Value());
$this->assertEquals('valueA', $field->children->fieldByName($field->getName() . '[_ConfirmPassword]')->Value());
$field->setValue('valueB');
$this->assertEquals('valueB', $field->Value());
$this->assertEquals('valueB', $field->children->fieldByName($field->getName() . '[_Password]')->Value());
$this->assertEquals('valueB', $field->children->fieldByName($field->getName() . '[_ConfirmPassword]')->Value());
}
public function testSetShowOnClick() {
//hide by default and display show/hide toggle button
$field = new ConfirmedPasswordField('Test', 'Testing', 'valueA', null, true);
$fieldHTML = $field->Field();
$this->assertContains("showOnClickContainer", $fieldHTML,
"Test class for hiding/showing the form contents is set");
$this->assertContains("showOnClick", $fieldHTML,
"Test class for hiding/showing the form contents is set");
//show all by default
$field = new ConfirmedPasswordField('Test', 'Testing', 'valueA', null, false);
$fieldHTML = $field->Field();
$this->assertNotContains("showOnClickContainer", $fieldHTML,
"Test class for hiding/showing the form contents is set");
$this->assertNotContains("showOnClick", $fieldHTML,
"Test class for hiding/showing the form contents is set");
}
}