Commit 6d8aa2d4 by Alexander Makarov

Fixed tests

parent d06f849a
......@@ -18,6 +18,14 @@ class ActiveFormTest extends \yiiunit\TestCase
$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()
{
$o = ['template' => '{input}'];
......@@ -27,14 +35,14 @@ class ActiveFormTest extends \yiiunit\TestCase
$form = new ActiveForm(['action' => '/something']);
ob_end_clean();
$this->assertEquals(<<<EOF
$this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required>
</div>
EOF
, (string) $form->field($model, 'name', $o)->input('email', ['required' => true]));
$this->assertEquals(<<<EOF
$this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]">
</div>
......@@ -42,7 +50,7 @@ EOF
, (string) $form->field($model, 'name', $o)->input('email', ['required' => false]));
$this->assertEquals(<<<EOF
$this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required="test">
</div>
......@@ -53,6 +61,8 @@ EOF
public function testIssue5356()
{
$o = ['template' => '{input}'];
$model = new DynamicModel(['categories']);
$model->categories = 1;
ob_start();
......@@ -60,11 +70,15 @@ EOF
ob_end_clean();
// https://github.com/yiisoft/yii2/issues/5356
$this->assertEquals(<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required>
$this->assertEqualsWithoutLE(<<<EOF
<div class="form-group field-dynamicmodel-categories">
<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>
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