Skip to content

Commit

Permalink
Merge branch 'form-helper' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 2, 2011
2 parents 0366d8f + bef2e75 commit c2a9626
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 512 deletions.
6 changes: 0 additions & 6 deletions lib/Cake/Test/Case/Utility/DebuggerTest.php
Expand Up @@ -237,12 +237,6 @@ public function testExportVar() {
View::$cacheAction = false View::$cacheAction = false
View::$validationErrors = array View::$validationErrors = array
View::$hasRendered = false View::$hasRendered = false
View::$modelScope = false
View::$model = NULL
View::$association = NULL
View::$field = NULL
View::$fieldSuffix = NULL
View::$modelId = NULL
View::$uuids = array View::$uuids = array
View::$output = false View::$output = false
View::$request = NULL View::$request = NULL
Expand Down
31 changes: 9 additions & 22 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -775,23 +775,23 @@ public function testValidateHashNoModel() {
*/ */
public function testDuplicateFieldNameResolution() { public function testDuplicateFieldNameResolution() {
$result = $this->Form->create('ValidateUser'); $result = $this->Form->create('ValidateUser');
$this->assertEqual($this->View->entity(), array('ValidateUser')); $this->assertEqual($this->Form->entity(), array('ValidateUser'));


$result = $this->Form->input('ValidateItem.name'); $result = $this->Form->input('ValidateItem.name');
$this->assertEqual($this->View->entity(), array('ValidateItem', 'name')); $this->assertEqual($this->Form->entity(), array('ValidateItem', 'name'));


$result = $this->Form->input('ValidateUser.name'); $result = $this->Form->input('ValidateUser.name');
$this->assertEqual($this->View->entity(), array('ValidateUser', 'name')); $this->assertEqual($this->Form->entity(), array('ValidateUser', 'name'));
$this->assertPattern('/name="data\[ValidateUser\]\[name\]"/', $result); $this->assertPattern('/name="data\[ValidateUser\]\[name\]"/', $result);
$this->assertPattern('/type="text"/', $result); $this->assertPattern('/type="text"/', $result);


$result = $this->Form->input('ValidateItem.name'); $result = $this->Form->input('ValidateItem.name');
$this->assertEqual($this->View->entity(), array('ValidateItem', 'name')); $this->assertEqual($this->Form->entity(), array('ValidateItem', 'name'));
$this->assertPattern('/name="data\[ValidateItem\]\[name\]"/', $result); $this->assertPattern('/name="data\[ValidateItem\]\[name\]"/', $result);
$this->assertPattern('/<textarea/', $result); $this->assertPattern('/<textarea/', $result);


$result = $this->Form->input('name'); $result = $this->Form->input('name');
$this->assertEqual($this->View->entity(), array('ValidateUser', 'name')); $this->assertEqual($this->Form->entity(), array('ValidateUser', 'name'));
$this->assertPattern('/name="data\[ValidateUser\]\[name\]"/', $result); $this->assertPattern('/name="data\[ValidateUser\]\[name\]"/', $result);
$this->assertPattern('/type="text"/', $result); $this->assertPattern('/type="text"/', $result);
} }
Expand Down Expand Up @@ -1528,12 +1528,12 @@ public function testFormValidationMultiRecord() {
)); ));
$result = $this->Form->input('Contact.2.name'); $result = $this->Form->input('Contact.2.name');
$expected = array( $expected = array(
'div' => array('class'), 'div' => array('class' => 'input text error'),
'label' => array('for'), 'label' => array('for' => 'Contact2Name'),
'preg:/[^<]+/', 'Name',
'/label', '/label',
'input' => array( 'input' => array(
'type' => 'text', 'name', 'id', 'type' => 'text', 'name' => 'data[Contact][2][name]', 'id' => 'Contact2Name',
'class' => 'form-error', 'maxlength' => 255 'class' => 'form-error', 'maxlength' => 255
), ),
array('div' => array('class' => 'error-message')), array('div' => array('class' => 'error-message')),
Expand Down Expand Up @@ -4702,19 +4702,6 @@ public function testDateTime() {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);


$result = $this->Form->input('ContactTag');
$expected = array(
'div' => array('class' => 'input select'),
'label' => array('for' => 'ContactTagContactTag'),
'Contact Tag',
'/label',
array('input' => array('type' => 'hidden', 'name' => 'data[ContactTag][ContactTag]', 'value' => '', 'id' => 'ContactTagContactTag_')),
array('select' => array('name' => 'data[ContactTag][ContactTag][]', 'multiple' => 'multiple', 'id' => 'ContactTagContactTag')),
'/select',
'/div'
);
$this->assertTags($result, $expected);

$this->Form->create('Contact'); $this->Form->create('Contact');
$result = $this->Form->input('published', array('monthNames' => false)); $result = $this->Form->input('published', array('monthNames' => false));
$now = strtotime('now'); $now = strtotime('now');
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
Expand Up @@ -1299,11 +1299,11 @@ public function testUseTag() {
$result = $this->Html->useTag('formend'); $result = $this->Html->useTag('formend');
$this->assertTags($result, '/form'); $this->assertTags($result, '/form');


$result = $this->Html->useTag('form', ' test'); $result = $this->Html->useTag('form', 'url', ' test');
$this->assertEqual($result, '<form test>'); $this->assertEqual($result, '<form action="url" test>');


$result = $this->Html->useTag('form', array('test' => 'ok')); $result = $this->Html->useTag('form', 'example.com', array('test' => 'ok'));
$this->assertTags($result, array('form' => array('test' => 'ok'))); $this->assertTags($result, array('form' => array('test' => 'ok', 'action' => 'example.com')));
} }


/** /**
Expand Down

0 comments on commit c2a9626

Please sign in to comment.