Browse Source

Move test from FormHelper into SelectBox widget test.

Closes #3931 as I am unable to reproduce the original issue.
mark_story 11 years ago
parent
commit
6b796b77dc

+ 0 - 7
tests/TestCase/View/Helper/FormHelperTest.php

@@ -2573,13 +2573,6 @@ class FormHelperTest extends TestCase {
 		);
 		$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',

+ 25 - 0
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;
@@ -107,6 +108,30 @@ class SelectBoxTest extends TestCase {
 	}
 
 /**
+ * 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
  *
  * @return void