From 222037df7d98aef426018a2f976d95184bc07d94 Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Thu, 28 Mar 2024 16:27:15 +0800 Subject: [PATCH] update --- composer.json | 10 +++--- phpunit.xml.dist | 18 ++++------ src/BootstrapAsset.php | 2 +- src/BootstrapPluginAsset.php | 2 +- tests/AccordionTest.php | 17 ++++----- tests/ActiveFieldDefaultFormCheckTest.php | 2 +- tests/ActiveFieldTest.php | 6 ++-- tests/ActiveFormTest.php | 4 +-- tests/ButtonDropdownTest.php | 2 +- tests/CarouselTest.php | 2 +- tests/HtmlTest.php | 2 +- tests/LinkPagerTest.php | 26 +++++++------- tests/ModalTest.php | 2 +- tests/NavBarTest.php | 10 +++--- tests/NavTest.php | 2 +- tests/OffcanvasTest.php | 2 +- tests/PopoverTest.php | 6 ++-- tests/TabsTest.php | 42 +++++++++++------------ tests/TestCase.php | 6 ++-- tests/ToastTest.php | 8 +++-- tests/ToggleButtonGroupTest.php | 4 +-- tests/TranslationTest.php | 2 +- tests/data/ExtendedActiveField.php | 2 +- 23 files changed, 89 insertions(+), 90 deletions(-) diff --git a/composer.json b/composer.json index 3e666fe..bdd34a2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "yiisoft/yii2-bootstrap5", - "description": "The Twitter Bootstrap v5 extension for the Yii framework", + "name": "x221/yii2-bootstrap5-mod", + "description": "The Twitter Bootstrap v5 extension for the Yii framework (Mod Version)", "keywords": [ "yii2", "bootstrap", @@ -9,7 +9,7 @@ "type": "yii2-extension", "license": "BSD-3-Clause", "support": { - "source": "https://github.com/yiisoft/yii2-bootstrap5" + "source": "https://git.chenx221.cyou/chenx221/yii2-bootstrap5-mod" }, "authors": [ { @@ -27,11 +27,11 @@ "php": ">=7.0", "ext-json": "*", "yiisoft/yii2": "^2.0.42", - "bower-asset/bootstrap": "^5.1.0" + "npm-asset/bootstrap": "^5.3.0" }, "require-dev": { "yiisoft/yii2-coding-standards": "~2.0", - "phpunit/phpunit": "^6.5.14", + "phpunit/phpunit": ">=8.5", "twbs/bootstrap-icons": "^1.7.2" }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5311924..ddd0495 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,8 @@ - - - - ./tests - - + + + + ./tests + + diff --git a/src/BootstrapAsset.php b/src/BootstrapAsset.php index 88fcf97..2790a09 100644 --- a/src/BootstrapAsset.php +++ b/src/BootstrapAsset.php @@ -19,7 +19,7 @@ class BootstrapAsset extends AssetBundle /** * @inheritDoc */ - public $sourcePath = '@bower/bootstrap'; + public $sourcePath = '@npm/bootstrap'; /** * @inheritDoc diff --git a/src/BootstrapPluginAsset.php b/src/BootstrapPluginAsset.php index 840d341..188f50d 100644 --- a/src/BootstrapPluginAsset.php +++ b/src/BootstrapPluginAsset.php @@ -19,7 +19,7 @@ class BootstrapPluginAsset extends AssetBundle /** * @inheritDoc */ - public $sourcePath = '@bower/bootstrap'; + public $sourcePath = '@npm/bootstrap'; /** * @inheritDoc diff --git a/tests/AccordionTest.php b/tests/AccordionTest.php index a5ba014..b55bb71 100644 --- a/tests/AccordionTest.php +++ b/tests/AccordionTest.php @@ -204,7 +204,7 @@ HTML , $output); } - public function invalidItemsProvider() + public static function invalidItemsProvider() { return [ [['content']], // only content without label key @@ -215,10 +215,11 @@ HTML /** * @dataProvider invalidItemsProvider - * @expectedException \yii\base\InvalidConfigException + * */ public function testMissingLabel($items) { + $this->expectException(\yii\base\InvalidConfigException::class); Accordion::widget([ 'items' => $items, ]); @@ -278,12 +279,12 @@ HTML $output = Accordion::widget([ 'items' => $items ]); - $this->assertContains('data-bs-parent="', $output); + $this->assertStringContainsString('data-bs-parent="', $output); $output = Accordion::widget([ 'autoCloseItems' => false, 'items' => $items ]); - $this->assertNotContains('data-bs-parent="', $output); + $this->assertStringNotContainsString('data-bs-parent="', $output); } /** @@ -310,8 +311,8 @@ HTML 'class' => 'custom-toggle', ], ]); - $this->assertContains('
assertNotContains('assertStringContainsString('
assertStringNotContainsString(' $items, @@ -320,7 +321,7 @@ HTML 'class' => ['widget' => 'custom-toggle'], ], ]); - $this->assertContains('
assertNotContains('collapse-toggle', $output); + $this->assertStringContainsString('
assertStringNotContainsString('collapse-toggle', $output); } } diff --git a/tests/ActiveFieldDefaultFormCheckTest.php b/tests/ActiveFieldDefaultFormCheckTest.php index f03aaf6..24d7c8b 100644 --- a/tests/ActiveFieldDefaultFormCheckTest.php +++ b/tests/ActiveFieldDefaultFormCheckTest.php @@ -189,7 +189,7 @@ HTML; $this->assertContainsWithoutLE($expected3, $out); } - protected function setUp() + protected function setUp(): void { // dirty way to have Request object not throwing exception when running testHomeLinkNull() $_SERVER['SCRIPT_FILENAME'] = 'index.php'; diff --git a/tests/ActiveFieldTest.php b/tests/ActiveFieldTest.php index 6d82135..a89357a 100644 --- a/tests/ActiveFieldTest.php +++ b/tests/ActiveFieldTest.php @@ -291,7 +291,7 @@ HTML; ] ])->render(); - $this->assertContains('data-attribute="test"', $content); + $this->assertStringContainsString('data-attribute="test"', $content); } /** @@ -306,10 +306,10 @@ HTML; ] ])->render(); - $this->assertContains('data-attribute="test"', $content); + $this->assertStringContainsString('data-attribute="test"', $content); } - protected function setUp() + protected function setUp(): void { // dirty way to have Request object not throwing exception when running testHomeLinkNull() $_SERVER['SCRIPT_FILENAME'] = "index.php"; diff --git a/tests/ActiveFormTest.php b/tests/ActiveFormTest.php index 2b1458b..eda55bd 100644 --- a/tests/ActiveFormTest.php +++ b/tests/ActiveFormTest.php @@ -397,7 +397,7 @@ HTML; { $form = ActiveForm::widget(); - $this->assertNotContains('role="form"', $form); + $this->assertStringNotContainsString('role="form"', $form); } public function testErrorSummaryRendering() @@ -418,7 +418,7 @@ HTML; $this->assertContainsWithoutLE('
assertContains("$containerClass dropup btn-group", $out); + $this->assertStringContainsString("$containerClass dropup btn-group", $out); } public function testDirection() diff --git a/tests/CarouselTest.php b/tests/CarouselTest.php index f086636..93a3290 100644 --- a/tests/CarouselTest.php +++ b/tests/CarouselTest.php @@ -90,6 +90,6 @@ HTML; ] ]); - $this->assertContains('class="carousel slide carousel-fade"', $out); + $this->assertStringContainsString('class="carousel slide carousel-fade"', $out); } } diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index aa29cf2..aef1001 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -13,7 +13,7 @@ class HtmlTest extends TestCase /** * @return array */ - public function dataProviderStaticControl() + public static function dataProviderStaticControl() { return [ [ diff --git a/tests/LinkPagerTest.php b/tests/LinkPagerTest.php index 25ab380..4d8dd4b 100644 --- a/tests/LinkPagerTest.php +++ b/tests/LinkPagerTest.php @@ -25,22 +25,22 @@ class LinkPagerTest extends TestCase 'firstPageLabel' => true, 'lastPageLabel' => true, ]); - $this->assertContains('
  • 1
  • ', $output); - $this->assertContains('
  • 25
  • ', $output); + $this->assertStringContainsString('
  • 1
  • ', $output); + $this->assertStringContainsString('
  • 25
  • ', $output); $output = LinkPager::widget([ 'pagination' => $pagination, 'firstPageLabel' => 'First', 'lastPageLabel' => 'Last', ]); - $this->assertContains('
  • First
  • ', $output); - $this->assertContains('
  • Last
  • ', $output); + $this->assertStringContainsString('
  • First
  • ', $output); + $this->assertStringContainsString('
  • Last
  • ', $output); $output = LinkPager::widget([ 'pagination' => $pagination, 'firstPageLabel' => false, 'lastPageLabel' => false, ]); - $this->assertNotContains('
  • ', $output); - $this->assertNotContains('
  • ', $output); + $this->assertStringNotContainsString('
  • ', $output); + $this->assertStringNotContainsString('
  • ', $output); } public function testDisabledPageElementOptions() @@ -49,7 +49,7 @@ class LinkPagerTest extends TestCase 'pagination' => $this->getPagination(0), 'disabledListItemSubTagOptions' => ['class' => ['foo-bar']], ]); - $this->assertContains('
  • 6
  • ', $output); + $this->assertStringContainsString('
  • 6
  • ', $output); $output = LinkPager::widget([ 'pagination' => $pagination, 'disableCurrentPageButton' => true, ]); - $this->assertContains('
  • 6
  • ', $output); + $this->assertStringContainsString('
  • 6
  • ', $output); } public function testOptionsWithTagOption() @@ -100,11 +100,11 @@ class LinkPagerTest extends TestCase 'class' => 'my-class', ], ]); - $this->assertContains( + $this->assertStringContainsString( '', $output ); - $this->assertContains( + $this->assertStringContainsString( '', $output ); @@ -125,7 +125,7 @@ class LinkPagerTest extends TestCase $this->assertTrue($initTriggered); } - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->mockWebApplication([ diff --git a/tests/ModalTest.php b/tests/ModalTest.php index ff05f08..e30e656 100644 --- a/tests/ModalTest.php +++ b/tests/ModalTest.php @@ -108,7 +108,7 @@ HTML; Modal::end(); $out = ob_get_clean(); - $this->assertContains( + $this->assertStringContainsString( '', $out ); diff --git a/tests/NavBarTest.php b/tests/NavBarTest.php index 85f042a..1310253 100644 --- a/tests/NavBarTest.php +++ b/tests/NavBarTest.php @@ -46,9 +46,9 @@ EXPECTED; 'brandUrl' => '/', ]); - $this->assertContains('', $out); + $this->assertStringContainsString('', $out); } - + public function testBrandImageOptions() { $out = NavBar::widget([ @@ -57,7 +57,7 @@ EXPECTED; 'brandUrl' => '/', ]); - $this->assertContains('test image', $out); + $this->assertStringContainsString('test image', $out); } public function testBrandLink() @@ -67,7 +67,7 @@ EXPECTED; 'brandUrl' => false, ]); - $this->assertContains('Yii Framework', $out); + $this->assertStringContainsString('Yii Framework', $out); } public function testBrandSpan() @@ -77,7 +77,7 @@ EXPECTED; 'brandUrl' => null, ]); - $this->assertContains('Yii Framework', $out); + $this->assertStringContainsString('Yii Framework', $out); } /** diff --git a/tests/NavTest.php b/tests/NavTest.php index 630a6da..f632bdf 100644 --- a/tests/NavTest.php +++ b/tests/NavTest.php @@ -347,7 +347,7 @@ EXPECTED; $this->assertEqualsWithoutLE($expected, $out); } - protected function setUp() + protected function setUp(): void { $this->mockWebApplication([ 'components' => [ diff --git a/tests/OffcanvasTest.php b/tests/OffcanvasTest.php index dad015b..1786ae7 100644 --- a/tests/OffcanvasTest.php +++ b/tests/OffcanvasTest.php @@ -86,7 +86,7 @@ HTML; Offcanvas::end(); $out = ob_get_clean(); - $this->assertContains( + $this->assertStringContainsString( '', $out ); diff --git a/tests/PopoverTest.php b/tests/PopoverTest.php index 681b3a8..53f0ecc 100644 --- a/tests/PopoverTest.php +++ b/tests/PopoverTest.php @@ -36,7 +36,8 @@ HTML; $js = Yii::$app->view->js[View::POS_READY]; - $this->assertInternalType(IsType::TYPE_ARRAY, $js); +// $this->assertInternalType(IsType::TYPE_ARRAY, $js); + $this->assertIsArray($js); $options = array_shift($js); $this->assertContainsWithoutLE("(new bootstrap.Popover('#w0', {", $options); @@ -55,7 +56,8 @@ HTML; $js = Yii::$app->view->js[View::POS_READY]; - $this->assertInternalType(IsType::TYPE_ARRAY, $js); +// $this->assertInternalType(IsType::TYPE_ARRAY, $js); + $this->assertIsArray($js); $options = array_shift($js); $this->assertContainsWithoutLE('"content":"\u003Cspan class=\u0022test-content\u0022\u003ETest content\u003C\/span\u003E"', $options); diff --git a/tests/TabsTest.php b/tests/TabsTest.php index 2ca9528..84c6f1e 100644 --- a/tests/TabsTest.php +++ b/tests/TabsTest.php @@ -140,11 +140,11 @@ class TabsTest extends TestCase ] ]); - $this->assertNotContains('InvisiblePage', $html); - $this->assertNotContains('Invisible Page Content', $html); - $this->assertNotContains('InvisibleItem', $html); - $this->assertNotContains('Invisible Item Content', $html); - $this->assertNotContains('Invisible External Link', $html); + $this->assertStringNotContainsString('InvisiblePage', $html); + $this->assertStringNotContainsString('Invisible Page Content', $html); + $this->assertStringNotContainsString('InvisibleItem', $html); + $this->assertStringNotContainsString('Invisible Item Content', $html); + $this->assertStringNotContainsString('Invisible External Link', $html); } public function testDisabled() @@ -179,23 +179,23 @@ class TabsTest extends TestCase ] ]); - $this->assertContains( + $this->assertStringContainsString( '', $html ); - $this->assertContains( + $this->assertStringContainsString( '', $html ); - $this->assertContains( + $this->assertStringContainsString( '', $html ); - $this->assertContains( + $this->assertStringContainsString( 'DisabledItem', $html ); - $this->assertContains( + $this->assertStringContainsString( 'Disabled External Link', $html ); @@ -220,7 +220,7 @@ class TabsTest extends TestCase 'renderTabContent' => true, ]); - $this->assertContains('<' . $checkTag, $out); + $this->assertStringContainsString('<' . $checkTag, $out); } public function testTabContentOptions() @@ -240,8 +240,8 @@ class TabsTest extends TestCase ] ]); - $this->assertContains($checkAttribute . '=', $out); - $this->assertContains($checkValue, $out); + $this->assertStringContainsString($checkAttribute . '=', $out); + $this->assertStringContainsString($checkValue, $out); } public function testActivateFirstVisibleTab() @@ -270,15 +270,15 @@ class TabsTest extends TestCase ] ]); - $this->assertNotContains( + $this->assertStringNotContainsString( '', $html ); - $this->assertNotContains( + $this->assertStringNotContainsString( '', $html ); - $this->assertContains( + $this->assertStringContainsString( '', $html ); @@ -309,7 +309,7 @@ class TabsTest extends TestCase ] ] ]); - $this->assertContains( + $this->assertStringContainsString( '', $html ); @@ -336,9 +336,9 @@ class TabsTest extends TestCase ], ] ]); - $this->assertContains('<span>encoded</span>', $html); - $this->assertContains('not encoded', $html); - $this->assertContains('not encoded too', $html); + $this->assertStringContainsString('<span>encoded</span>', $html); + $this->assertStringContainsString('not encoded', $html); + $this->assertStringContainsString('not encoded too', $html); } /** @@ -403,6 +403,6 @@ HTML;
    Content 2
    HTML; - $this->assertEquals($expected, $html); + $this->assertEqualsWithoutLE($expected, $html); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index d4ad53a..1516f46 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -39,13 +39,13 @@ class TestCase extends \PHPUnit\Framework\TestCase $needle = str_replace("\r\n", "\n", $needle); $haystack = str_replace("\r\n", "\n", $haystack); - $this->assertContains($needle, $haystack); + $this->assertStringContainsString($needle, $haystack); } /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->mockWebApplication(); @@ -54,7 +54,7 @@ class TestCase extends \PHPUnit\Framework\TestCase /** * {@inheritDoc} */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); $this->destroyApplication(); diff --git a/tests/ToastTest.php b/tests/ToastTest.php index af9319c..07b22cd 100644 --- a/tests/ToastTest.php +++ b/tests/ToastTest.php @@ -132,12 +132,13 @@ HTML; Toast::end(); $out = ob_get_clean(); - $this->assertInternalType(IsType::TYPE_ARRAY, $toast->clientOptions); + $this->assertIsArray($toast->clientOptions); $this->assertCount(0, $toast->clientOptions); $js = Yii::$app->view->js[View::POS_READY]; - $this->assertInternalType(IsType::TYPE_ARRAY, $js); +// $this->assertInternalType(IsType::TYPE_ARRAY, $js); + $this->assertIsArray($js); $options = array_shift($js); $this->assertContainsWithoutLE("(new bootstrap.Toast('#w0', {}));", $options); @@ -180,7 +181,8 @@ HTML; $this->assertArrayHasKey(View::POS_READY, Yii::$app->view->js); $js = Yii::$app->view->js[View::POS_READY]; - $this->assertInternalType(IsType::TYPE_ARRAY, $js); +// $this->assertInternalType(IsType::TYPE_ARRAY, $js); + $this->assertIsArray($js); $options = array_shift($js); $this->assertContainsWithoutLE("(new bootstrap.Toast('#w0', {\"delay\":1000}));", $options); diff --git a/tests/ToggleButtonGroupTest.php b/tests/ToggleButtonGroupTest.php index f603cf2..9954c3c 100644 --- a/tests/ToggleButtonGroupTest.php +++ b/tests/ToggleButtonGroupTest.php @@ -48,7 +48,7 @@ HTML; ], ]); - $this->assertContains('', $html); + $this->assertStringContainsString('', $html); } public function testRadio() @@ -88,7 +88,7 @@ HTML; ], ]); - $this->assertContains('', $html); + $this->assertStringContainsString('', $html); } } diff --git a/tests/TranslationTest.php b/tests/TranslationTest.php index 31b2a30..7bdf52f 100644 --- a/tests/TranslationTest.php +++ b/tests/TranslationTest.php @@ -11,7 +11,7 @@ use yii\bootstrap5\Breadcrumbs; class TranslationTest extends TestCase { - protected function setUp() + protected function setUp(): void { $this->mockWebApplication([ 'language' => 'de-CH', diff --git a/tests/data/ExtendedActiveField.php b/tests/data/ExtendedActiveField.php index 95c87ac..a85de08 100644 --- a/tests/data/ExtendedActiveField.php +++ b/tests/data/ExtendedActiveField.php @@ -13,7 +13,7 @@ use yii\bootstrap5\ActiveField; */ class ExtendedActiveField extends ActiveField { - public ?array $horizontalCssClasses = [ + public $horizontalCssClasses = [ 'offset' => 'col-md-offset-4', 'label' => 'col-md-4', 'wrapper' => 'col-md-6',