|
|
@@ -2498,9 +2498,8 @@ class FormHelperTest extends TestCase {
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testFormInputs() {
|
|
|
- $this->markTestIncomplete('Need to revisit once models work again.');
|
|
|
- $this->Form->create('Cake\Test\TestCase\View\Helper\Contact');
|
|
|
+ public function testFormInputsLegendFieldset() {
|
|
|
+ $this->Form->create($this->article);
|
|
|
$result = $this->Form->inputs('The Legend');
|
|
|
$expected = array(
|
|
|
'<fieldset',
|
|
|
@@ -2511,210 +2510,100 @@ class FormHelperTest extends TestCase {
|
|
|
);
|
|
|
$this->assertTags($result, $expected);
|
|
|
|
|
|
- $result = $this->Form->inputs(array('legend' => 'Field of Dreams', 'fieldset' => 'classy-stuff'));
|
|
|
- $expected = array(
|
|
|
- 'fieldset' => array('class' => 'classy-stuff'),
|
|
|
- '<legend',
|
|
|
- 'Field of Dreams',
|
|
|
- '/legend',
|
|
|
- '*/fieldset'
|
|
|
- );
|
|
|
- $this->assertTags($result, $expected);
|
|
|
+ $result = $this->Form->inputs(null, null, array('legend' => 'Field of Dreams', 'fieldset' => true));
|
|
|
+ $this->assertContains('<legend>Field of Dreams</legend>', $result);
|
|
|
+ $this->assertContains('<fieldset>', $result);
|
|
|
|
|
|
- $result = $this->Form->inputs(null, null, array('legend' => 'Field of Dreams', 'fieldset' => 'classy-stuff'));
|
|
|
- $this->assertTags($result, $expected);
|
|
|
+ $result = $this->Form->inputs('Field of Dreams', null, array('fieldset' => true));
|
|
|
+ $this->assertContains('<legend>Field of Dreams</legend>', $result);
|
|
|
+ $this->assertContains('<fieldset>', $result);
|
|
|
|
|
|
- $result = $this->Form->inputs('Field of Dreams', null, array('fieldset' => 'classy-stuff'));
|
|
|
- $this->assertTags($result, $expected);
|
|
|
+ $result = $this->Form->inputs(null, null, array('fieldset' => false, 'legend' => false));
|
|
|
+ $this->assertNotContains('<legend>', $result);
|
|
|
+ $this->assertNotContains('<fieldset>', $result);
|
|
|
|
|
|
- $this->Form->create('Contact');
|
|
|
- $this->Form->request['prefix'] = 'admin';
|
|
|
- $this->Form->request['action'] = 'admin_edit';
|
|
|
+ $result = $this->Form->inputs(null, null, array('fieldset' => false, 'legend' => 'Hello'));
|
|
|
+ $this->assertNotContains('<legend>', $result);
|
|
|
+ $this->assertNotContains('<fieldset>', $result);
|
|
|
+
|
|
|
+ $this->Form->create($this->article);
|
|
|
+ $this->Form->request->params['prefix'] = 'admin';
|
|
|
+ $this->Form->request->params['action'] = 'admin_edit';
|
|
|
+ $this->Form->request->params['controller'] = 'articles';
|
|
|
$result = $this->Form->inputs();
|
|
|
- $expected = array(
|
|
|
+ $expected = [
|
|
|
'<fieldset',
|
|
|
'<legend',
|
|
|
- 'Edit Contact',
|
|
|
+ 'New Article',
|
|
|
'/legend',
|
|
|
'*/fieldset',
|
|
|
- );
|
|
|
+ ];
|
|
|
$this->assertTags($result, $expected);
|
|
|
+ }
|
|
|
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(false);
|
|
|
+/**
|
|
|
+ * Test the inputs() method.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testFormInputs() {
|
|
|
+ $this->Form->create($this->article);
|
|
|
+ $result = $this->Form->inputs();
|
|
|
$expected = array(
|
|
|
- 'input' => array('type' => 'hidden', 'name' => 'Contact[id]', 'id' => 'ContactId'),
|
|
|
- array('div' => array('class' => 'input text')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input email')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input tel')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input password')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input datetime')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input number')),
|
|
|
+ '<fieldset',
|
|
|
+ '<legend', 'New Article', '/legend',
|
|
|
+ 'input' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id'),
|
|
|
+ array('div' => array('class' => 'input select required')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input select')),
|
|
|
+ array('div' => array('class' => 'input text required')),
|
|
|
'*/div',
|
|
|
- );
|
|
|
- $this->assertTags($result, $expected);
|
|
|
-
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(array('fieldset' => false, 'legend' => false));
|
|
|
- $expected = array(
|
|
|
- 'input' => array('type' => 'hidden', 'name' => 'Contact[id]', 'id' => 'ContactId'),
|
|
|
array('div' => array('class' => 'input text')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input email')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input tel')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input password')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input datetime')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input number')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input select')),
|
|
|
- '*/div',
|
|
|
- );
|
|
|
- $this->assertTags($result, $expected);
|
|
|
-
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(null, null, array('fieldset' => false));
|
|
|
- $this->assertTags($result, $expected);
|
|
|
-
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(array('fieldset' => true, 'legend' => false));
|
|
|
- $expected = array(
|
|
|
- 'fieldset' => array(),
|
|
|
- 'input' => array('type' => 'hidden', 'name' => 'Contact[id]', 'id' => 'ContactId'),
|
|
|
array('div' => array('class' => 'input text')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input email')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input tel')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input password')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input datetime')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input number')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input select')),
|
|
|
- '*/div',
|
|
|
- '/fieldset'
|
|
|
+ '/fieldset',
|
|
|
);
|
|
|
$this->assertTags($result, $expected);
|
|
|
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(array('fieldset' => false, 'legend' => 'Hello'));
|
|
|
+ $result = $this->Form->inputs([
|
|
|
+ 'published' => ['type' => 'boolean']
|
|
|
+ ]);
|
|
|
$expected = array(
|
|
|
- 'input' => array('type' => 'hidden', 'name' => 'Contact[id]', 'id' => 'ContactId'),
|
|
|
- array('div' => array('class' => 'input text')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input email')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input tel')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input password')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
+ '<fieldset',
|
|
|
+ '<legend', 'New Article', '/legend',
|
|
|
+ 'input' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id'),
|
|
|
+ array('div' => array('class' => 'input select required')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input datetime')),
|
|
|
+ array('div' => array('class' => 'input text required')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input number')),
|
|
|
+ array('div' => array('class' => 'input text')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input select')),
|
|
|
+ array('div' => array('class' => 'input boolean')),
|
|
|
'*/div',
|
|
|
+ '/fieldset',
|
|
|
);
|
|
|
$this->assertTags($result, $expected);
|
|
|
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(null, null, array('fieldset' => false, 'legend' => 'Hello'));
|
|
|
- $this->assertTags($result, $expected);
|
|
|
-
|
|
|
- $this->Form->create('Contact');
|
|
|
+ $this->Form->create($this->article);
|
|
|
$result = $this->Form->inputs('Hello');
|
|
|
$expected = array(
|
|
|
'fieldset' => array(),
|
|
|
'legend' => array(),
|
|
|
'Hello',
|
|
|
'/legend',
|
|
|
- 'input' => array('type' => 'hidden', 'name' => 'Contact[id]', 'id' => 'ContactId'),
|
|
|
- array('div' => array('class' => 'input text')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input email')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input tel')),
|
|
|
+ 'input' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id'),
|
|
|
+ array('div' => array('class' => 'input select required')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input password')),
|
|
|
+ array('div' => array('class' => 'input text required')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input datetime')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input number')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input select')),
|
|
|
- '*/div',
|
|
|
- '/fieldset'
|
|
|
- );
|
|
|
- $this->assertTags($result, $expected);
|
|
|
-
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(array('legend' => 'Hello'));
|
|
|
- $expected = array(
|
|
|
- 'fieldset' => array(),
|
|
|
- 'legend' => array(),
|
|
|
- 'Hello',
|
|
|
- '/legend',
|
|
|
- 'input' => array('type' => 'hidden', 'name' => 'Contact[id]', 'id' => 'ContactId'),
|
|
|
array('div' => array('class' => 'input text')),
|
|
|
'*/div',
|
|
|
- array('div' => array('class' => 'input email')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input tel')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input password')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input date')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input datetime')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input number')),
|
|
|
- '*/div',
|
|
|
- array('div' => array('class' => 'input select')),
|
|
|
+ array('div' => array('class' => 'input text')),
|
|
|
'*/div',
|
|
|
'/fieldset'
|
|
|
);
|
|
|
$this->assertTags($result, $expected);
|
|
|
|
|
|
- $this->Form->create('Contact');
|
|
|
- $result = $this->Form->inputs(null, null, array('legend' => 'Hello'));
|
|
|
- $this->assertTags($result, $expected);
|
|
|
- $this->Form->end();
|
|
|
-
|
|
|
$this->Form->create(false);
|
|
|
$expected = array(
|
|
|
'fieldset' => array(),
|