diff --git a/.editorconfig b/.editorconfig index 257221d2..5e9a93ea 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,3 +12,6 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bb9c6d45..ea75bda5 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -3,5 +3,5 @@ Contributing to Yii2 - [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md) - [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md) -- [Give us feedback or start a design discussion](https://forum.yiiframework.com/c/yii-2-0/general-discussions/16) +- [Give us feedback or start a design discussion](https://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/) - [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 9908ebfa..205e8498 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -2,4 +2,4 @@ open_collective: yiisoft github: [yiisoft] -tidelift: "packagist/yiisoft/yii2-bootstrap" +tidelift: "packagist/yiisoft/yii2-bootstrap5" diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index fb58a29f..d4fd500d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,7 +5,7 @@ Yii communities listed at https://github.com/yiisoft/yii2/wiki/communities ### What steps will reproduce the problem? -### What's expected? +### What is the expected result? ### What do you get instead? diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65c872d2..301d1355 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,47 +1,31 @@ -name: build +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'psalm.xml' -on: [push, pull_request] + push: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'psalm.xml' -env: - DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi" +name: build jobs: - phpunit: - name: PHP ${{ matrix.php }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache composer dependencies - uses: actions/cache@v1 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - name: Install dependencies - run: composer update $DEFAULT_COMPOSER_FLAGS - - name: Run unit tests with coverage - run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always - if: matrix.php == '7.1' - - name: Run unit tests without coverage - run: vendor/bin/phpunit --verbose --colors=always - if: matrix.php != '7.1' - - name: Upload code coverage - run: | - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - if: matrix.php == '7.1' - continue-on-error: true # if is fork + phpunit: + uses: yiisoft/actions/.github/workflows/phpunit.yml@master + with: + os: >- + ['ubuntu-latest'] + php: >- + ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] diff --git a/README.md b/README.md index 58e60034..e48d3bc4 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,12 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md). [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-bootstrap/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-bootstrap/downloads.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap) [![Build Status](https://github.com/yiisoft/yii2-bootstrap/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-bootstrap/actions) +[![codecov](https://codecov.io/gh/yiisoft/yii2-bootstrap/graph/badge.svg?token=WgenN23NcE)](https://codecov.io/gh/yiisoft/yii2-bootstrap) +Requirements +------------ + +- PHP 7.3 or higher. Installation ------------ diff --git a/composer.json b/composer.json index b71f545a..b92429d2 100644 --- a/composer.json +++ b/composer.json @@ -32,12 +32,12 @@ } ], "require": { + "php": ">=7.3", "yiisoft/yii2": "~2.0.6", "bower-asset/bootstrap": "3.4.* | 3.3.* | 3.2.* | 3.1.*" }, "require-dev": { - "cweagans/composer-patches": "^1.7", - "phpunit/phpunit": "4.8.34" + "phpunit/phpunit": "^9.6" }, "repositories": [ { @@ -53,20 +53,10 @@ "extra": { "branch-alias": { "dev-master": "2.0.x-dev" - }, - "patches": { - "phpunit/phpunit-mock-objects": { - "Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch" - }, - "phpunit/phpunit": { - "Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch", - "Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch" - } } }, "config": { "allow-plugins": { - "cweagans/composer-patches": true, "yiisoft/yii2-composer": true } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a2bff895..b0a906c9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,27 @@ - - - - ./tests - - + + + + + + + + + ./tests + + + + + + ./src + + diff --git a/tests/ActiveFieldTest.php b/tests/ActiveFieldTest.php index 84b26f6e..7624de08 100644 --- a/tests/ActiveFieldTest.php +++ b/tests/ActiveFieldTest.php @@ -27,7 +27,7 @@ class ActiveFieldTest extends TestCase */ private $attributeName = 'attributeName'; - protected function setUp() + protected function setUp(): void { // dirty way to have Request object not throwing exception when running testHomeLinkNull() $_SERVER['SCRIPT_FILENAME'] = "index.php"; @@ -93,7 +93,7 @@ public function testRadioListItemOptions() ] ])->render(); - $this->assertContains('data-attribute="test"', $content); + $this->assertStringContainsString('data-attribute="test"', $content); } /** @@ -109,7 +109,7 @@ public function testCheckboxListItemOptions() ] ])->render(); - $this->assertContains('data-attribute="test"', $content); + $this->assertStringContainsString('data-attribute="test"', $content); } public function testHorizontalCssClasses() diff --git a/tests/ActiveFormTest.php b/tests/ActiveFormTest.php index 1de73063..af13ebe8 100644 --- a/tests/ActiveFormTest.php +++ b/tests/ActiveFormTest.php @@ -5,13 +5,13 @@ /** * Tests for ActiveForm widget - * + * * @group bootstrap */ class ActiveFormTest extends TestCase { - protected function setUp() + protected function setUp(): void { // dirty way to have Request object not throwing exception when running testFormNoRoleAttribute() $_SERVER['REQUEST_URI'] = "index.php"; @@ -27,6 +27,6 @@ public function testFormNoRoleAttribute() { $form = ActiveForm::widget(); - $this->assertNotContains('role="form"', $form); + $this->assertStringNotContainsString('role="form"', $form); } } diff --git a/tests/ButtonDropdownTest.php b/tests/ButtonDropdownTest.php index 8b12dc04..f6e7ad51 100644 --- a/tests/ButtonDropdownTest.php +++ b/tests/ButtonDropdownTest.php @@ -26,6 +26,6 @@ public function testContainerOptions() ], ]); - $this->assertContains("$containerClass btn-group", $out); + $this->assertStringContainsString("$containerClass btn-group", $out); } } diff --git a/tests/ButtonGroupTest.php b/tests/ButtonGroupTest.php index a38a65b3..a32a4c25 100644 --- a/tests/ButtonGroupTest.php +++ b/tests/ButtonGroupTest.php @@ -21,9 +21,9 @@ public function testContainerOptions() ], ]); - static::assertContains('button-A', $out); - static::assertContains('button-B', $out); - static::assertContains('button-B', $out); - static::assertNotContains('button-C', $out); + static::assertStringContainsString('button-A', $out); + static::assertStringContainsString('button-B', $out); + static::assertStringContainsString('button-B', $out); + static::assertStringNotContainsString('button-C', $out); } } diff --git a/tests/CollapseTest.php b/tests/CollapseTest.php index bf3dbae6..94e9c73f 100644 --- a/tests/CollapseTest.php +++ b/tests/CollapseTest.php @@ -2,6 +2,7 @@ namespace yiiunit\extensions\bootstrap; use yii\base\DynamicModel; +use yii\base\InvalidConfigException; use yii\bootstrap\Collapse; use yii\widgets\ActiveForm; @@ -170,13 +171,13 @@ public function invalidItemsProvider() /** * @dataProvider invalidItemsProvider - * @expectedException \yii\base\InvalidConfigException */ public function testMissingLabel($items) { - Collapse::widget([ - 'items' => $items, - ]); + $this->expectException(InvalidConfigException::class); + $this->expectExceptionMessage("The 'label' option is required."); + + Collapse::widget(['items' => $items]); } /** @@ -231,12 +232,12 @@ public function testAutoCloseItems() $output = Collapse::widget([ 'items' => $items ]); - $this->assertContains('data-parent="', $output); + $this->assertStringContainsString('data-parent="', $output); $output = Collapse::widget([ 'autoCloseItems' => false, 'items' => $items ]); - $this->assertNotContains('data-parent="', $output); + $this->assertStringNotContainsString('data-parent="', $output); } /** @@ -262,8 +263,11 @@ public function testItemToggleTag() 'class' => 'custom-toggle', ], ]); - $this->assertContains('