Commit 6d8aa2d4 by Alexander Makarov

Fixed tests

parent d06f849a
...@@ -18,6 +18,14 @@ class ActiveFormTest extends \yiiunit\TestCase ...@@ -18,6 +18,14 @@ class ActiveFormTest extends \yiiunit\TestCase
$this->mockApplication(); $this->mockApplication();
} }
public function assertEqualsWithoutLE($expected, $actual)
{
$expected = str_replace("\r\n", "\n", $expected);
$actual = str_replace("\r\n", "\n", $actual);
$this->assertEquals($expected, $actual);
}
public function testBooleanAttributes() public function testBooleanAttributes()
{ {
$o = ['template' => '{input}']; $o = ['template' => '{input}'];
...@@ -27,14 +35,14 @@ class ActiveFormTest extends \yiiunit\TestCase ...@@ -27,14 +35,14 @@ class ActiveFormTest extends \yiiunit\TestCase
$form = new ActiveForm(['action' => '/something']); $form = new ActiveForm(['action' => '/something']);
ob_end_clean(); ob_end_clean();
$this->assertEquals(<<<EOF $this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-name"> <div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required> <input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required>
</div> </div>
EOF EOF
, (string) $form->field($model, 'name', $o)->input('email', ['required' => true])); , (string) $form->field($model, 'name', $o)->input('email', ['required' => true]));
$this->assertEquals(<<<EOF $this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-name"> <div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]"> <input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]">
</div> </div>
...@@ -42,7 +50,7 @@ EOF ...@@ -42,7 +50,7 @@ EOF
, (string) $form->field($model, 'name', $o)->input('email', ['required' => false])); , (string) $form->field($model, 'name', $o)->input('email', ['required' => false]));
$this->assertEquals(<<<EOF $this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-name"> <div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required="test"> <input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required="test">
</div> </div>
...@@ -53,6 +61,8 @@ EOF ...@@ -53,6 +61,8 @@ EOF
public function testIssue5356() public function testIssue5356()
{ {
$o = ['template' => '{input}'];
$model = new DynamicModel(['categories']); $model = new DynamicModel(['categories']);
$model->categories = 1; $model->categories = 1;
ob_start(); ob_start();
...@@ -60,11 +70,15 @@ EOF ...@@ -60,11 +70,15 @@ EOF
ob_end_clean(); ob_end_clean();
// https://github.com/yiisoft/yii2/issues/5356 // https://github.com/yiisoft/yii2/issues/5356
$this->assertEquals(<<<EOF $this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-name"> <div class="form-group field-dynamicmodel-categories">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required> <input type="hidden" name="DynamicModel[categories]" value=""><select id="dynamicmodel-categories" class="form-control" name="DynamicModel[categories][]" multiple size="4">
<option value="0">apple</option>
<option value="1" selected>banana</option>
<option value="2">avocado</option>
</select>
</div> </div>
EOF EOF
, (string) $form->field($model, 'categories')->listBox(['apple', 'banana', 'avocado'], ['multiple' => true])); , (string) $form->field($model, 'categories', $o)->listBox(['apple', 'banana', 'avocado'], ['multiple' => true]));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment