removed @depends constraints (cause problems with php 8)

This commit is contained in:
Simon Karlen 2021-08-04 08:21:51 +02:00
parent 3edb6b4b97
commit 520a475f6e
No known key found for this signature in database
GPG Key ID: 0630C27D666EBCC3
18 changed files with 160 additions and 157 deletions

View File

@ -1,7 +1,9 @@
<?php
namespace yiiunit\extensions\bootstrap5;
use yii\base\DynamicModel;
use yii\base\InvalidConfigException;
use yii\bootstrap5\Accordion;
use yii\widgets\ActiveForm;
@ -131,7 +133,7 @@ HTML
'label' => 'Item3',
'content' => 'Content3',
],
'FormField' => $form->field(new DynamicModel(['test']), 'test',['template' => '{input}']),
'FormField' => $form->field(new DynamicModel(['test']), 'test', ['template' => '{input}']),
]
]);
@ -205,9 +207,9 @@ HTML
public function invalidItemsProvider()
{
return [
[ ['content'] ], // only content without label key
[ [[]] ], // only content array without label
[ [['content' => 'test']] ], // only content array without label
[['content']], // only content without label key
[[[]]], // only content array without label
[[['content' => 'test']]], // only content array without label
];
}
@ -285,7 +287,6 @@ HTML
}
/**
* @depends testRender
*/
public function testItemToggleTag()
{

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;
use Yii;
@ -27,57 +28,6 @@ class ActiveFieldDefaultFormCheckTest extends TestCase
*/
private $_attributeName = 'attributeName';
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';
$this->mockWebApplication([
'container' => [
'definitions' => [
'yii\bootstrap5\ActiveField' => [
'checkTemplate' => "<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>",
'radioTemplate' => "<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>",
'checkHorizontalTemplate' => "{beginWrapper}\n<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>\n{endWrapper}",
'radioHorizontalTemplate' => "{beginWrapper}\n<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>\n{endWrapper}",
'checkOptions' => [
'class' => ['widget' => 'form-check-input'],
'labelOptions' => [
'class' => ['widget' => 'form-check-label']
],
'wrapperOptions' => [
'class' => ['widget' => 'form-check']
]
],
'radioOptions' => [
'class' => ['widget' => 'form-check-input'],
'labelOptions' => [
'class' => ['widget' => 'form-check-label']
],
'wrapperOptions' => [
'class' => ['widget' => 'form-check']
]
]
]
]
]
]);
$this->_helperModel = new DynamicModel(['attributeName']);
ob_start();
$this->_helperForm = ActiveForm::begin(['action' => '/something']);
ActiveForm::end();
ob_end_clean();
$this->_activeField = Yii::createObject([
'class' => 'yii\bootstrap5\ActiveField',
'form' => $this->_helperForm
]);
$this->_activeField->model = $this->_helperModel;
$this->_activeField->attribute = $this->_attributeName;
}
public function testDefaultCheckboxByConfig()
{
Html::$counter = 0;
@ -238,4 +188,55 @@ HTML;
$this->assertContainsWithoutLE($expected2, $out);
$this->assertContainsWithoutLE($expected3, $out);
}
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';
$this->mockWebApplication([
'container' => [
'definitions' => [
'yii\bootstrap5\ActiveField' => [
'checkTemplate' => "<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>",
'radioTemplate' => "<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>",
'checkHorizontalTemplate' => "{beginWrapper}\n<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>\n{endWrapper}",
'radioHorizontalTemplate' => "{beginWrapper}\n<div class=\"form-check\">\n{input}\n{label}\n{error}\n{hint}\n</div>\n{endWrapper}",
'checkOptions' => [
'class' => ['widget' => 'form-check-input'],
'labelOptions' => [
'class' => ['widget' => 'form-check-label']
],
'wrapperOptions' => [
'class' => ['widget' => 'form-check']
]
],
'radioOptions' => [
'class' => ['widget' => 'form-check-input'],
'labelOptions' => [
'class' => ['widget' => 'form-check-label']
],
'wrapperOptions' => [
'class' => ['widget' => 'form-check']
]
]
]
]
]
]);
$this->_helperModel = new DynamicModel(['attributeName']);
ob_start();
$this->_helperForm = ActiveForm::begin(['action' => '/something']);
ActiveForm::end();
ob_end_clean();
$this->_activeField = Yii::createObject([
'class' => 'yii\bootstrap5\ActiveField',
'form' => $this->_helperForm
]);
$this->_activeField->model = $this->_helperModel;
$this->_activeField->attribute = $this->_attributeName;
}
}

View File

@ -26,25 +26,6 @@ class ActiveFieldTest extends TestCase
*/
private $attributeName = 'attributeName';
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();
$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;
}
public function testFileInput()
{
Html::$counter = 0;
@ -62,8 +43,6 @@ HTML;
$this->assertEqualsWithoutLE($expectedHtml, $html);
}
// Tests :
public function testRadioList()
{
Html::$counter = 0;
@ -89,6 +68,8 @@ HTML;
$this->assertEqualsWithoutLE($expectedHtml, $html);
}
// Tests :
public function testRadioError()
{
Html::$counter = 0;
@ -257,7 +238,6 @@ HTML;
}
/**
* @depends testRadioList
*
* @see https://github.com/yiisoft/yii2-bootstrap/issues/81
*/
@ -274,7 +254,6 @@ HTML;
}
/**
* @depends testCheckboxList
*
* @see https://github.com/yiisoft/yii2-bootstrap/issues/81
*/
@ -289,4 +268,23 @@ HTML;
$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();
$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;
}
}

View File

@ -15,15 +15,6 @@ use yiiunit\extensions\bootstrap5\data\User;
class ActiveFormTest extends TestCase
{
protected function setUp()
{
// dirty way to have Request object not throwing exception when running testFormNoRoleAttribute()
$_SERVER['REQUEST_URI'] = "index.php";
parent::setUp();
}
public function testDefaultLayout()
{
ActiveForm::$counter = 0;
@ -124,7 +115,6 @@ HTML;
}
/**
* @depends testHorizontalLayout
*/
public function testHorizontalLayoutTemplateOverride()
{
@ -375,4 +365,13 @@ HTML;
$this->assertContainsWithoutLE('<div class="alert alert-danger"', $out);
}
protected function setUp()
{
// dirty way to have Request object not throwing exception when running testFormNoRoleAttribute()
$_SERVER['REQUEST_URI'] = "index.php";
parent::setUp();
}
}

View File

@ -34,7 +34,6 @@ HTML;
}
/**
* @depends testNormalAlert
*/
public function testDismissibleAlert()
{

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;
use yii\bootstrap5\Button;

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;
@ -58,7 +59,6 @@ HTML;
}
/**
* @depends testContainerOptions
*/
public function testCrossfade()
{

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;
use yii\bootstrap5\Dropdown;

View File

@ -17,32 +17,6 @@ use yii\helpers\StringHelper;
*/
class LinkPagerTest extends TestCase
{
protected function setUp()
{
parent::setUp();
$this->mockWebApplication([
'components' => [
'urlManager' => [
'scriptUrl' => '/',
],
],
]);
}
/**
* Get pagination.
* @param int $page
* @return Pagination
*/
private function getPagination($page)
{
$pagination = new Pagination();
$pagination->setPage($page);
$pagination->totalCount = 500;
$pagination->route = 'test';
return $pagination;
}
public function testFirstLastPageLabels()
{
$pagination = $this->getPagination(5);
@ -79,7 +53,6 @@ class LinkPagerTest extends TestCase
}
/**
* @depends testDisabledPageElementOptions
*/
public function testOverrideDisabledPageElementOptions()
{
@ -151,4 +124,31 @@ class LinkPagerTest extends TestCase
]);
$this->assertTrue($initTriggered);
}
protected function setUp()
{
parent::setUp();
$this->mockWebApplication([
'components' => [
'urlManager' => [
'scriptUrl' => '/',
],
],
]);
}
/**
* Get pagination.
* @param int $page
* @return Pagination
*/
private function getPagination($page)
{
$pagination = new Pagination();
$pagination->setPage($page);
$pagination->totalCount = 500;
$pagination->route = 'test';
return $pagination;
}
}

View File

@ -38,7 +38,6 @@ HTML;
}
/**
* @depends testBodyOptions
*/
public function testContainerOptions()
{

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;
use yii\bootstrap5\Nav;
@ -68,9 +69,9 @@ EXPECTED;
}
/**
* @depends testRender
*/
public function testNavAndForm() {
public function testNavAndForm()
{
NavBar::$counter = 0;

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;
use yii\bootstrap5\Nav;
@ -10,26 +11,6 @@ use yii\bootstrap5\Nav;
*/
class NavTest extends TestCase
{
protected function setUp()
{
$this->mockWebApplication([
'components' => [
'request' => [
'class' => 'yii\web\Request',
'scriptUrl' => '/base/index.php',
'hostInfo' => 'http://example.com/',
'url' => '/base/index.php&r=site%2Fcurrent&id=42'
],
'urlManager' => [
'class' => 'yii\web\UrlManager',
'baseUrl' => '/base',
'scriptUrl' => '/base/index.php',
'hostInfo' => 'http://example.com/',
]
],
]);
}
public function testIds()
{
Nav::$counter = 0;
@ -365,4 +346,24 @@ EXPECTED;
$this->assertEqualsWithoutLE($expected, $out);
}
protected function setUp()
{
$this->mockWebApplication([
'components' => [
'request' => [
'class' => 'yii\web\Request',
'scriptUrl' => '/base/index.php',
'hostInfo' => 'http://example.com/',
'url' => '/base/index.php&r=site%2Fcurrent&id=42'
],
'urlManager' => [
'class' => 'yii\web\UrlManager',
'baseUrl' => '/base',
'scriptUrl' => '/base/index.php',
'hostInfo' => 'http://example.com/',
]
],
]);
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace yiiunit\extensions\bootstrap5;
@ -46,7 +47,6 @@ HTML;
}
/**
* @depends testRender
*/
public function testMultiple()
{

View File

@ -33,7 +33,6 @@ HTML;
}
/**
* @depends testBodyOptions
*/
public function testContainerOptions()
{

View File

@ -32,9 +32,9 @@ HTML;
}
/**
* @depends testCheckbox
*/
public function testCheckboxChecked() {
public function testCheckboxChecked()
{
Html::$counter = 0;
$html = ToggleButtonGroup::widget([
'type' => ToggleButtonGroup::TYPE_CHECKBOX,
@ -70,9 +70,9 @@ HTML;
}
/**
* @depends testRadio
*/
public function testRadioChecked() {
public function testRadioChecked()
{
Html::$counter = 0;
$html = ToggleButtonGroup::widget([
'type' => ToggleButtonGroup::TYPE_RADIO,

View File

@ -21,7 +21,9 @@ class Singer extends Model
[['lastName'], 'default', 'value' => 'Lennon'],
[['lastName'], 'required'],
[['underscore_style'], 'yii\captcha\CaptchaValidator'],
[['test'], 'required', 'when' => function($model) { return $model->firstName === 'cebe'; }],
[['test'], 'required', 'when' => function ($model) {
return $model->firstName === 'cebe';
}],
];
}
}