Skip to content

Commit

Permalink
Test Case for Formhelper Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu Cammaert committed Feb 29, 2012
1 parent cd2dca2 commit 9c24f81
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -6528,8 +6528,8 @@ public function testCreateCustomRoute() {
*/ */
public function testCreateWithInputDefaults() { public function testCreateWithInputDefaults() {
$this->Form->create('User', array( $this->Form->create('User', array(
'inputDefaults' => array('div' => false, 'label' => false) 'inputDefaults' => array('div' => false, 'label' => false, 'error' => array('attributes'=>array('wrap' => 'small', 'class' => 'error')))
)); ));
$result = $this->Form->input('username'); $result = $this->Form->input('username');
$expected = array( $expected = array(
'input' => array('type' => 'text', 'name' => 'data[User][username]', 'id' => 'UserUsername') 'input' => array('type' => 'text', 'name' => 'data[User][username]', 'id' => 'UserUsername')
Expand All @@ -6544,6 +6544,18 @@ public function testCreateWithInputDefaults() {
'/div' '/div'
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);

$User = ClassRegistry::getObject('User');
$User->validationErrors['username'] = array('empty');
$result = $this->Form->input('username', array('div' => true, 'label' => 'username', 'error' => array('empty' => __('Required'))));
$expected = array(
'div' => array('class' => 'input text error'),
'label' => array('for' => 'UserUsername'), 'username', '/label',
'input' => array('class' => 'form-error', 'type' => 'text', 'name' => 'data[User][username]', 'id' => 'UserUsername'),
'small' => array('class' => 'error'), 'Required', '/small',
'/div'
);
$this->assertTags($result, $expected);
} }


/** /**
Expand Down

0 comments on commit 9c24f81

Please sign in to comment.