]*class="error-message"[^<>]*>.*<\/div>/', $result);
- $result = $this->Form->input('Address.1.last_name');
- $this->assertPattern('/
]*class="error-message"[^<>]*>You must have a last name<\/div>/', $result);
+ function testMultipleInputValidation() {
+ $this->Form->create();
+ $this->Form->validationErrors['Address'][0]['title'] = 'This field cannot be empty';
+ $this->Form->validationErrors['Address'][0]['first_name'] = 'This field cannot be empty';
+ $this->Form->validationErrors['Address'][1]['last_name'] = 'You must have a last name';
+
+ $result = $this->Form->input('Address.0.title');
+ $expected = array(
+ 'div' => array('class' => 'preg:/.+/'),
+ 'label' => array('for' => 'preg:/.+/'),
+ 'preg:/.+/',
+ '!label',
+ 'input' => array('type' => 'text', 'name' => 'preg:/.+/', 'value' => '', 'id' => 'preg:/.+/', 'class' => 'form-error'),
+ array('div' => array('class' => 'error-message')),
+ 'This field cannot be empty',
+ array('!div'),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->input('Address.0.first_name');
+ $expected = array(
+ 'div' => array('class' => 'preg:/.+/'),
+ 'label' => array('for' => 'preg:/.+/'),
+ 'preg:/.+/',
+ '!label',
+ 'input' => array('type' => 'text', 'name' => 'preg:/.+/', 'value' => '', 'id' => 'preg:/.+/', 'class' => 'form-error'),
+ array('div' => array('class' => 'error-message')),
+ 'This field cannot be empty',
+ array('!div'),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->input('Address.0.last_name');
+ $expected = array(
+ 'div' => array('class' => 'preg:/.+/'),
+ 'label' => array('for' => 'preg:/.+/'),
+ 'preg:/.+/',
+ '!label',
+ 'input' => array('type' => 'text', 'name' => 'preg:/.+/', 'value' => '', 'id' => 'preg:/.+/', 'class' => 'form-error'),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->input('Address.1.last_name');
+ $expected = array(
+ 'div' => array('class' => 'preg:/.+/'),
+ 'label' => array('for' => 'preg:/.+/'),
+ 'preg:/.+/',
+ '!label',
+ 'input' => array('type' => 'text', 'name' => 'preg:/.+/', 'value' => '', 'id' => 'preg:/.+/', 'class' => 'form-error'),
+ array('div' => array('class' => 'error-message')),
+ 'You must have a last name',
+ array('!div'),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
}
function testFormInput() {
$result = $this->Form->input('Contact.email', array('id' => 'custom'));
- $expected = '
';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ 'div' => array('class' => 'input'),
+ 'label' => array('for' => 'custom'),
+ 'Email',
+ '!label',
+ array('input' => array('type' => 'text', 'name' => 'data[Contact][email]', 'value' => '', 'id' => 'custom')),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
$result = $this->Form->hidden('Contact/idontexist');
- $expected = '
';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ 'input' => array('type' => 'hidden', 'name' => 'data[Contact][idontexist]', 'value' => '', 'id' => 'ContactIdontexist'),
+ );
+ $this->assertTags($result, $expected);
$result = $this->Form->input('Contact.email', array('type' => 'text'));
- $expected = '
';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ 'div' => array('class' => 'input'),
+ 'label' => array('for' => 'ContactEmail'),
+ 'Email',
+ '!label',
+ array('input' => array('type' => 'text', 'name' => 'data[Contact][email]', 'value' => '', 'id' => 'ContactEmail')),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
$result = $this->Form->input('Contact.5.email', array('type' => 'text'));
- $expected = '
';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ 'div' => array('class' => 'input'),
+ 'label' => array('for' => 'Contact5Email'),
+ 'Email',
+ '!label',
+ array('input' => array('type' => 'text', 'name' => 'data[Contact][5][email]', 'value' => '', 'id' => 'Contact5Email')),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
$result = $this->Form->input('Contact/password');
- $expected = '
';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ 'div' => array('class' => 'input'),
+ 'label' => array('for' => 'ContactPassword'),
+ 'Password',
+ '!label',
+ array('input' => array('type' => 'password', 'name' => 'data[Contact][password]', 'value' => '', 'id' => 'ContactPassword')),
+ '!div'
+ );
+ $this->assertTags($result, $expected);
$result = $this->Form->input('email', array('options' => array('First', 'Second'), 'empty' => true));
- $this->assertPattern('/