From 6b796b77dc52b65f5fcc6afa1a8686f653e40fa2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Jul 2014 20:14:02 -0400 Subject: [PATCH] Move test from FormHelper into SelectBox widget test. Closes #3931 as I am unable to reproduce the original issue. --- tests/TestCase/View/Helper/FormHelperTest.php | 7 ------ tests/TestCase/View/Widget/SelectBoxTest.php | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/TestCase/View/Helper/FormHelperTest.php b/tests/TestCase/View/Helper/FormHelperTest.php index 08441aecd96..bf517cc3ac4 100755 --- a/tests/TestCase/View/Helper/FormHelperTest.php +++ b/tests/TestCase/View/Helper/FormHelperTest.php @@ -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', diff --git a/tests/TestCase/View/Widget/SelectBoxTest.php b/tests/TestCase/View/Widget/SelectBoxTest.php index 32504bf6c7f..e353e4d9cf4 100644 --- a/tests/TestCase/View/Widget/SelectBoxTest.php +++ b/tests/TestCase/View/Widget/SelectBoxTest.php @@ -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; @@ -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 *