activeField->fileInput()->render(); $expectedHtml = <<
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testRangeInput() { $html = $this->activeField->rangeInput()->render(); $expectedHtml = <<
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testColorInput() { $html = $this->activeField->colorInput()->render(); $expectedHtml = <<
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testRadioList() { $html = $this->activeField->radioList([1 => 'name1', 2 => 'name2'])->render(); $expectedHtml = <<
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } // Tests : public function testRadioError() { $this->helperModel->addError($this->attributeName, 'Test print error message'); $html = $this->activeField->radio()->render(); $expectedHtml = <<
Test print error message
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testRadioListError() { $this->helperModel->addError($this->attributeName, 'Test print error message'); $html = $this->activeField->radioList([1 => 'name1', 2 => 'name2'])->render(); $expectedHtml = <<
Test print error message
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testCheckboxList() { $html = $this->activeField->checkboxList([1 => 'name1', 2 => 'name2'])->render(); $expectedHtml = <<
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testCheckboxError() { $this->helperModel->addError($this->attributeName, 'Test print error message'); $html = $this->activeField->checkbox()->render(); $expectedHtml = <<
Test print error message
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testCheckboxListError() { $this->helperModel->addError($this->attributeName, 'Test print error message'); $html = $this->activeField->checkboxList([1 => 'name1', 2 => 'name2'])->render(); $expectedHtml = <<
Test print error message
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testRadioListInline() { $this->activeField->inline = true; $html = $this->activeField->radioList([1 => 'name1', 2 => 'name2'])->render(); $expectedHtml = <<
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } public function testCheckboxListInline() { $this->activeField->inline = true; $html = $this->activeField->checkboxList([1 => 'name1', 2 => 'name2'])->render(); $expectedHtml = <<
HTML; $this->assertEqualsWithoutLE($expectedHtml, $html); } /** * @see https://github.com/yiisoft/yii2-bootstrap/issues/81 */ public function testRadioListItemOptions() { $content = $this->activeField->radioList([1 => 'name1', 2 => 'name2'], [ 'itemOptions' => [ 'data-attribute' => 'test' ] ])->render(); $this->assertContains('data-attribute="test"', $content); } /** * * @see https://github.com/yiisoft/yii2-bootstrap/issues/81 */ public function testCheckboxListItemOptions() { $content = $this->activeField->checkboxList([1 => 'name1', 2 => 'name2'], [ 'itemOptions' => [ 'data-attribute' => 'test' ] ])->render(); $this->assertContains('data-attribute="test"', $content); } protected function setUp() { // dirty way to have Request object not throwing exception when running testHomeLinkNull() $_SERVER['SCRIPT_FILENAME'] = "index.php"; $_SERVER['SCRIPT_NAME'] = "index.php"; parent::setUp(); Html::$counter = 0; $this->helperModel = new DynamicModel(['attributeName']); ob_start(); $this->helperForm = ActiveForm::begin(['action' => '/something']); ActiveForm::end(); ob_end_clean(); $this->activeField = new ActiveField(['form' => $this->helperForm]); $this->activeField->model = $this->helperModel; $this->activeField->attribute = $this->attributeName; } }