From 83072b8334b502e797cf53e5cdacf576cf8b68d5 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 4 Oct 2023 10:07:58 -0300 Subject: [PATCH 1/3] Raise min `PHP` version to `PHP 7.3`, check compatibility `PHP 8.3`. --- .editorconfig | 3 ++ .github/workflows/build.yml | 70 ++++++++++++++----------------------- composer.json | 17 ++------- phpunit.xml.dist | 37 +++++++++++++------- tests/ExtensionTest.php | 4 +-- tests/TestCase.php | 2 +- tests/ViewRendererTest.php | 20 +++++------ tests/bootstrap.php | 2 -- tests/compatibility.php | 50 -------------------------- 9 files changed, 71 insertions(+), 134 deletions(-) delete mode 100644 tests/compatibility.php diff --git a/.editorconfig b/.editorconfig index 257221d23..5e9a93ea5 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/workflows/build.yml b/.github/workflows/build.yml index fbb1946ad..301d13558 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', '8.1'] - - 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/composer.json b/composer.json index 9153f8fbe..98156dd84 100644 --- a/composer.json +++ b/composer.json @@ -22,13 +22,13 @@ } ], "require": { + "php": ">=7.3", "yiisoft/yii2": "~2.0.0", "smarty/smarty": "^3.1.0 | ^4.2.0" }, "require-dev": { "yiisoft/yii2-coding-standards": "~2.0", - "cweagans/composer-patches": "^1.7", - "phpunit/phpunit": "4.8.34" + "phpunit/phpunit": "^9.6" }, "repositories": [ { @@ -49,23 +49,12 @@ "extra": { "branch-alias": { "dev-master": "2.0.x-dev" - }, - "composer-exit-on-patch-failure": true, - "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": { "secure-http": false, "allow-plugins": { - "yiisoft/yii2-composer": true, - "cweagans/composer-patches": true + "yiisoft/yii2-composer": true } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a2bff8953..ef39a6c69 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,27 @@ - - - - ./tests - - + + + + + + + + + ./tests + + + + + + ./src + + diff --git a/tests/ExtensionTest.php b/tests/ExtensionTest.php index 0e1a96e02..3ff2b540c 100644 --- a/tests/ExtensionTest.php +++ b/tests/ExtensionTest.php @@ -17,14 +17,14 @@ class ExtensionTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->mockWebApplication(); FileHelper::createDirectory(Yii::getAlias('@runtime/Smarty')); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); FileHelper::removeDirectory(Yii::getAlias('@runtime/Smarty')); diff --git a/tests/TestCase.php b/tests/TestCase.php index a1c9fda37..5cd80426b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -21,7 +21,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase * Clean up after test. * By default the application created with [[mockApplication]] will be destroyed. */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); $this->destroyApplication(); diff --git a/tests/ViewRendererTest.php b/tests/ViewRendererTest.php index 2cccf8778..bee761663 100644 --- a/tests/ViewRendererTest.php +++ b/tests/ViewRendererTest.php @@ -19,13 +19,13 @@ */ class ViewRendererTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->mockWebApplication(); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); FileHelper::removeDirectory(Yii::getAlias('@runtime/assets')); @@ -105,8 +105,8 @@ public function testUse() { $view = $this->mockView(); $content = $view->renderFile('@yiiunit/smarty/views/use.tpl'); - $this->assertContains('
assertStringContainsString('mockView(); $content = $view->renderFile('@yiiunit/smarty/views/use.tpl'); $view->renderFile('@yiiunit/smarty/views/extended-layout.tpl', ['content' => $content]); - $this->assertContains('assertStringContainsString('mockView(); $content = $view->renderFile('@yiiunit/smarty/views/widget-default.tpl'); - $this->assertContains('
test
', $content); + $this->assertStringContainsString('
test
', $content); } public function testWidgetHidden() { $view = $this->mockView(); $content = $view->renderFile('@yiiunit/smarty/views/widget-invalid.tpl'); - $this->assertNotContains('
test
', $content); + $this->assertStringNotContainsString('
test
', $content); } public function testRegisterBlocks() @@ -169,11 +169,11 @@ public function testRegisterBlocks() ]; $content = $view->render('@yiiunit/smarty/views/register-blocks.tpl'); $content = $view->renderFile('@yiiunit/smarty/views/layout-block.tpl', ['content' => $content]); - $this->assertContains('', $content); - $this->assertContains('', $content); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ed539ca7e..b90a3c34e 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,5 +13,3 @@ Yii::setAlias('@yiiunit/smarty', __DIR__); Yii::setAlias('@yii/smarty', dirname(__DIR__) . '/src'); - -require_once(__DIR__ . '/compatibility.php'); diff --git a/tests/compatibility.php b/tests/compatibility.php deleted file mode 100644 index 95e4cd1bc..000000000 --- a/tests/compatibility.php +++ /dev/null @@ -1,50 +0,0 @@ -setExpectedException($exception); - } - - /** - * @param string $message - */ - public function expectExceptionMessage($message) - { - $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase'); - if (in_array('expectExceptionMessage', $parentClassMethods)) { - parent::expectExceptionMessage($message); - return; - } - $this->setExpectedException($this->getExpectedException(), $message); - } - - /** - * @param string $messageRegExp - */ - public function expectExceptionMessageRegExp($messageRegExp) - { - $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase'); - if (in_array('expectExceptionMessageRegExp', $parentClassMethods)) { - parent::expectExceptionMessageRegExp($messageRegExp); - return; - } - $this->setExpectedExceptionRegExp($this->getExpectedException(), $messageRegExp); - } - } - } -} From 8a96827a0f8b9e3fc50ee47effd00a16bccc40b8 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 4 Oct 2023 10:10:30 -0300 Subject: [PATCH 2/3] Update metadata. --- .github/CONTRIBUTING.md | 2 +- .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE.md | 15 +++++++-------- .github/PULL_REQUEST_TEMPLATE.md | 12 ++++++------ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 3d8d32c25..ea75bda5f 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](http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/) +- [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 8992d2322..205e84988 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -2,4 +2,4 @@ open_collective: yiisoft github: [yiisoft] -tidelift: "packagist/yiisoft/yii2-smarty" +tidelift: "packagist/yiisoft/yii2-bootstrap5" diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 54a5ef18e..d4fd500d7 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,16 +5,15 @@ 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? + ### Additional info -| Q | A -| ------------------ | --- -| Yii version | -| Yii Smarty version | -| Smarty version | -| PHP version | -| Operating system | +| Q | A +| ---------------- | --- +| Yii vesion | +| PHP version | +| Operating system | diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6b188bc11..cecccf6dc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ -| Q | A | -|--------------|--------------------------------------------------------------------| -| Is bugfix? | ✔️/❌ | -| New feature? | ✔️/❌ | -| Breaks BC? | ✔️/❌ | -| Fixed issues | | +| Q | A +| ------------- | --- +| Is bugfix? | ✔️/❌ +| New feature? | ✔️/❌ +| Breaks BC? | ✔️/❌ +| Fixed issues | From d856cdc0fe91b7c64a4744e4de686a806a70b661 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 4 Oct 2023 10:13:11 -0300 Subject: [PATCH 3/3] Update `README.md`. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 0cb3f24d4..647c1ed36 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,12 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md). [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-smarty/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-smarty) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-smarty/downloads.png)](https://packagist.org/packages/yiisoft/yii2-smarty) [![Build Status](https://github.com/yiisoft/yii2-smarty/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-smarty/actions) +[![codecov](https://codecov.io/gh/yiisoft/yii2-smarty/graph/badge.svg?token=6dBHWO0kMO)](https://codecov.io/gh/yiisoft/yii2-smarty) +Requirements +------------ + +- PHP 7.3 or higher. Installation ------------