Skip to content
This repository
Browse code

adding test case

  • Loading branch information...
commit 5064601c6f3b02c4a30c2e989f3fd67d8962f0bf 1 parent 9a9ac6f
Mark authored October 23, 2012
23  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -2650,6 +2650,29 @@ public function testInputWithMatchingFieldAndModelName() {
2650 2650
 			'/div'
2651 2651
 		);
2652 2652
 		$this->assertTags($result, $expected);
  2653
+
  2654
+		$this->View->viewVars['balances'] = array(0 => 'nothing', 1 => 'some', 100 => 'a lot');
  2655
+		$this->Form->request->data = array('ValidateUser' => array('balance' => 1));
  2656
+		$result = $this->Form->input('ValidateUser.balance');
  2657
+		$expected = array(
  2658
+			'div' => array('class' => 'input select'),
  2659
+			'label' => array('for' => 'ValidateUserBalance'),
  2660
+			'Balance',
  2661
+			'/label',
  2662
+			'select' => array('name' => 'data[ValidateUser][balance]', 'id' => 'ValidateUserBalance'),
  2663
+			array('option' => array('value' => '0')),
  2664
+			'nothing',
  2665
+			'/option',
  2666
+			array('option' => array('value' => '1', 'selected' => 'selected')),
  2667
+			'some',
  2668
+			'/option',
  2669
+			array('option' => array('value' => '100')),
  2670
+			'a lot',
  2671
+			'/option',
  2672
+			'/select',
  2673
+			'/div'
  2674
+		);
  2675
+		$this->assertTags($result, $expected);
2653 2676
 	}
2654 2677
 
2655 2678
 /**
7  lib/Cake/View/Helper/FormHelper.php
@@ -1006,12 +1006,17 @@ public function input($fieldName, $options = array()) {
1006 1006
 				}
1007 1007
 				$options['options'] = $varOptions;
1008 1008
 			}
  1009
+
  1010
+			if ($options['type'] === 'select' && array_key_exists('step', $options)) {
  1011
+				unset($options['step']);
  1012
+			}
1009 1013
 		}
1010 1014
 
1011 1015
 		$autoLength = (
1012 1016
 			!array_key_exists('maxlength', $options) &&
1013 1017
 			isset($fieldDef['length']) &&
1014  
-			is_scalar($fieldDef['length'])
  1018
+			is_scalar($fieldDef['length']) &&
  1019
+		 	$options['type'] !== 'select'
1015 1020
 		);
1016 1021
 		if ($autoLength && $options['type'] == 'text') {
1017 1022
 			$options['maxlength'] = $fieldDef['length'];

0 notes on commit 5064601

Please sign in to comment.
Something went wrong with that request. Please try again.