added another test for #8848

close #8850
This commit is contained in:
Carsten Brandt
2015-06-21 23:18:09 +02:00
parent 6ab64c9b35
commit bda90b6ad3

View File

@ -16,8 +16,17 @@ use yii\web\AssetManager;
*/ */
class ActiveFieldTest extends \yiiunit\TestCase class ActiveFieldTest extends \yiiunit\TestCase
{ {
/**
* @var ActiveField
*/
private $activeField; private $activeField;
/**
* @var DynamicModel
*/
private $helperModel; private $helperModel;
/**
* @var ActiveForm
*/
private $helperForm; private $helperForm;
private $attributeName = 'attributeName'; private $attributeName = 'attributeName';
@ -246,6 +255,19 @@ EOD;
'value2' => ['label' => 'value 2'], 'value2' => ['label' => 'value 2'],
]]); ]]);
$this->assertEqualsWithoutLE($expectedValue, $this->activeField->parts['{input}']); $this->assertEqualsWithoutLE($expectedValue, $this->activeField->parts['{input}']);
$expectedValue = <<<EOD
<input type="hidden" name="DynamicModel[attributeName]" value=""><select id="dynamicmodel-attributename" class="form-control" name="DynamicModel[attributeName]" size="4">
<option value="value1" disabled>Item One</option>
<option value="value2" selected label="value 2">Item 2</option>
</select>
EOD;
$this->activeField->model->{$this->attributeName} = 'value2';
$this->activeField->listBox(["value1" => "Item One", "value2" => "Item 2"], ['options' => [
'value1' => ['disabled' => true],
'value2' => ['label' => 'value 2'],
]]);
$this->assertEqualsWithoutLE($expectedValue, $this->activeField->parts['{input}']);
} }
public function testGetClientOptionsReturnEmpty() public function testGetClientOptionsReturnEmpty()