Skip to content

Commit

Permalink
Move test from FormHelper into SelectBox widget test.
Browse files Browse the repository at this point in the history
Closes #3931 as I am unable to reproduce the original issue.
  • Loading branch information
markstory committed Jul 13, 2014
1 parent 6189cc1 commit 6b796b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
7 changes: 0 additions & 7 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -2573,13 +2573,6 @@ public function testInputSelectType() {
);
$this->assertTags($result, $expected);

$this->View->viewVars['users'] = null;
$result = $this->Form->input('Thing.user_id', array(
'options' => array('value' => 'good', 'other' => 'bad'),
'empty' => 'Some Empty'
));
$this->assertTags($result, $expected);

$this->Form->data = array();
$result = $this->Form->input('Publisher.id', array(
'label' => 'Publisher',
Expand Down
25 changes: 25 additions & 0 deletions tests/TestCase/View/Widget/SelectBoxTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\View\Widget;

use Cake\Collection\Collection;
use Cake\TestSuite\TestCase;
use Cake\View\StringTemplate;
use Cake\View\Widget\SelectBox;
Expand Down Expand Up @@ -106,6 +107,30 @@ public function testRenderSimpleIterator() {
$this->assertTags($result, $expected);
}

/**
* test simple iterator rendering with empty option
*
* @return void
*/
public function testRenderSimpleIteratorWithEmpty() {
$select = new SelectBox($this->templates);
$options = new Collection(['a' => 'Albatross', 'b' => 'Budgie']);
$data = [
'name' => 'Birds[name]',
'options' => $options,
'empty' => 'Pick one'
];
$result = $select->render($data, $this->context);
$expected = [
'select' => ['name' => 'Birds[name]'],
['option' => ['value' => '']], 'Pick one', '/option',
['option' => ['value' => 'a']], 'Albatross', '/option',
['option' => ['value' => 'b']], 'Budgie', '/option',
'/select'
];
$this->assertTags($result, $expected);
}

/**
* test complex option rendering
*
Expand Down

0 comments on commit 6b796b7

Please sign in to comment.