From b5bbe51b72581002654362e95607ccf482899372 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 4 Oct 2023 08:53:34 -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 | 20 ++--------- phpunit.xml.dist | 42 +++++++++++++--------- tests/TestCase.php | 2 +- tests/ViewRendererTest.php | 38 ++++++++++---------- tests/bootstrap.php | 2 -- tests/compatibility.php | 32 ----------------- 8 files changed, 77 insertions(+), 132 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 2aaab5b58..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: ['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 d3ed252c9..900c8eb07 100644 --- a/composer.json +++ b/composer.json @@ -18,13 +18,12 @@ } ], "require": { - "php": "^7.2.5|^8.0|^8.1", + "php": ">=7.3", "yiisoft/yii2": "~2.0.4", "twig/twig": "~3.0" }, "require-dev": { - "cweagans/composer-patches": "^1.7", - "phpunit/phpunit": "4.8.34" + "phpunit/phpunit": "^9.6" }, "repositories": [ { @@ -45,25 +44,10 @@ "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/php-file-iterator": { - "Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_path_file_iterator.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", - "Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php81.patch" - } } }, "config": { "allow-plugins": { - "cweagans/composer-patches": true, "yiisoft/yii2-composer": true } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cb1726e09..2bc83a074 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,27 @@ - - - - ./tests - - - - - src/ - - + + + + + + + + + ./tests + + + + + + ./src + + diff --git a/tests/TestCase.php b/tests/TestCase.php index 06cb3aec9..f5fcc29ea 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -20,7 +20,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 b7f3d22dc..b05cdfd6e 100644 --- a/tests/ViewRendererTest.php +++ b/tests/ViewRendererTest.php @@ -22,19 +22,19 @@ */ class ViewRendererTest extends TestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); Order::setUp(); } - 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')); @@ -84,23 +84,23 @@ public function testCalls() $view = $this->mockView(); $model = new Singer(); $content = $view->renderFile('@yiiunit/twig/views/calls.twig', ['model' => $model]); - $this->assertNotContains('silence', $content, 'silence should not be echoed when void() used'); - $this->assertContains('echo', $content); - $this->assertContains('variable', $content); + $this->assertStringNotContainsString('silence', $content, 'silence should not be echoed when void() used'); + $this->assertStringContainsString('echo', $content); + $this->assertStringContainsString('variable', $content); } public function testInheritance() { $view = $this->mockView(); $content = $view->renderFile('@yiiunit/twig/views/extends2.twig'); - $this->assertContains('Hello, I\'m inheritance test!', $content); - $this->assertContains('extends2 block', $content); - $this->assertNotContains('extends1 block', $content); + $this->assertStringContainsString('Hello, I\'m inheritance test!', $content); + $this->assertStringContainsString('extends2 block', $content); + $this->assertStringNotContainsString('extends1 block', $content); $content = $view->renderFile('@yiiunit/twig/views/extends3.twig'); - $this->assertContains('Hello, I\'m inheritance test!', $content); - $this->assertContains('extends3 block', $content); - $this->assertNotContains('extends1 block', $content); + $this->assertStringContainsString('Hello, I\'m inheritance test!', $content); + $this->assertStringContainsString('extends3 block', $content); + $this->assertStringNotContainsString('extends1 block', $content); } public function testChangeTitle() @@ -109,8 +109,8 @@ public function testChangeTitle() $view->title = 'Original title'; $content = $view->renderFile('@yiiunit/twig/views/changeTitle.twig'); - $this->assertContains('New title', $content); - $this->assertNotContains('Original title', $content); + $this->assertStringContainsString('New title', $content); + $this->assertStringNotContainsString('Original title', $content); } public function testNullsInAr() @@ -127,7 +127,7 @@ public function testPropertyAccess() $order = new Order(); $order->total = 42; $content = $view->renderFile('@yiiunit/twig/views/property.twig', ['order' => $order]); - $this->assertContains('42', $content); + $this->assertStringContainsString('42', $content); } public function testSimpleFilters() @@ -164,7 +164,7 @@ public function testTranslation() { $view = $this->mockView(); $content = $view->renderFile('@yiiunit/twig/views/t.twig'); - $this->assertContains('test<br>', $content); + $this->assertStringContainsString('test<br>', $content); } public function testHtmlExtension() @@ -260,9 +260,9 @@ public function testStaticAndConsts() $view = $this->mockView(); $view->renderers['twig']['globals']['staticClass'] = ['class' => \yiiunit\twig\data\StaticAndConsts::class]; $content = $view->renderFile('@yiiunit/twig/views/staticAndConsts.twig'); - $this->assertContains('I am a const!', $content); - $this->assertContains('I am a static var!', $content); - $this->assertContains('I am a static function with param pam-param!', $content); + $this->assertStringContainsString('I am a const!', $content); + $this->assertStringContainsString('I am a static var!', $content); + $this->assertStringContainsString('I am a static function with param pam-param!', $content); } public function testDate() diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 71b7a36f5..04022a025 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,5 +12,3 @@ require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); Yii::setAlias('@yiiunit/twig', __DIR__); - -require_once(__DIR__ . '/compatibility.php'); diff --git a/tests/compatibility.php b/tests/compatibility.php deleted file mode 100644 index f7fd3f29d..000000000 --- a/tests/compatibility.php +++ /dev/null @@ -1,32 +0,0 @@ -setExpectedException($exception); - } - - /** - * @param string $message - */ - public function expectExceptionMessage($message) - { - $this->setExpectedException($this->getExpectedException(), $message); - } - } - } -} From eeee102348c6b7e0b196483a5703f47306c79064 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 4 Oct 2023 08:58:08 -0300 Subject: [PATCH 2/3] Update `README.md`. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 117decf35..aa8ae39f3 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-twig/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-twig) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-twig/downloads.png)](https://packagist.org/packages/yiisoft/yii2-twig) [![Build Status](https://github.com/yiisoft/yii2-twig/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-twig/actions) +[![codecov](https://codecov.io/gh/yiisoft/yii2-twig/graph/badge.svg?token=9NTxihROa6)](https://codecov.io/gh/yiisoft/yii2-twig) +Requirements +------------ + +- PHP 7.3 or higher. Installation ------------ From 1f12205f0135140323a54e132bbf96c4d073b8e7 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Fri, 17 May 2024 13:25:30 -0400 Subject: [PATCH 3/3] Add php `8.4`. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 301d13558..a01614e4a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,4 +28,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']