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 d9bfdf490..1990fa198 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,71 +1,80 @@ name: build -on: [push, pull_request] +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' -env: - DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi" + push: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' jobs: - phpunit: - name: PHP ${{ matrix.php }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - services: - postgres: - image: postgres:9.6 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: yiitest - ports: - - 5432:5432 - options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 - 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', '8.2'] + phpunit: + name: PHP ${{ matrix.php }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + services: + postgres: + image: postgres:9.6 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: yiitest + ports: + - 5432:5432 + options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: pecl - extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached, mysql, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, sqlite - ini-values: date.timezone='UTC', session.save_path="${{ runner.temp }}" - - name: Get composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - name: Cache composer dependencies - uses: actions/cache@v3 - 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: Load database data - env: - PGHOST: 127.0.0.1 - PGUSER: postgres - PGDATABASE: yiitest - PGPASSWORD: postgres - PGPORT: ${{ job.services.postgres.ports['5432'] }} - run: | - sudo apt update && sudo apt --fix-broken install && sudo apt install -y postgresql-client - psql -U postgres yiitest < tests/data/pgsql.sql - echo " tests/data/config.local.php - - 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 + strategy: + matrix: + os: [ubuntu-latest] + php: ['7.3', '7.4', '8.1', '8.2', '8.3'] + + steps: + - name: Checkout. + uses: actions/checkout@v3 + + - name: Install PHP. + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: pecl + extensions: curl, dom, imagick, intl, mbstring, mcrypt, memcached, mysql, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, sqlite + ini-values: date.timezone='UTC', session.save_path="${{ runner.temp }}" + + - name: Install dependencies with composer. + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Load database data. + env: + PGHOST: 127.0.0.1 + PGUSER: postgres + PGDATABASE: yiitest + PGPASSWORD: postgres + PGPORT: ${{ job.services.postgres.ports['5432'] }} + run: | + sudo apt update && sudo apt --fix-broken install && sudo apt install -y postgresql-client + psql -U postgres yiitest < tests/data/pgsql.sql + echo " tests/data/config.local.php + + - name: Run tests with phpunit. + if: matrix.php != '8.1' + run: vendor/bin/phpunit --colors=always + + - name: Run tests with phpunit and generate coverage. + if: matrix.php == '8.1' + run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always + + - name: Upload coverage to Codecov. + if: matrix.php == '8.1' + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml diff --git a/README.md b/README.md index f0f2b7fa9..56b180fbf 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-gii/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-gii) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-gii/downloads.png)](https://packagist.org/packages/yiisoft/yii2-gii) [![Build Status](https://github.com/yiisoft/yii2-gii/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-gii/actions) +[![codecov](https://codecov.io/gh/yiisoft/yii2-gii/graph/badge.svg?token=cp8aJ7tGka)](https://codecov.io/gh/yiisoft/yii2-gii) +Requirements +------------ + +- PHP 7.3 or higher. Installation ------------ diff --git a/composer.json b/composer.json index 5483367b5..0b9f4f660 100644 --- a/composer.json +++ b/composer.json @@ -23,13 +23,13 @@ ], "minimum-stability": "dev", "require": { + "php": ">=7.3", "yiisoft/yii2": "~2.0.46", "phpspec/php-diff": "^1.1.0" }, "require-dev": { "yiisoft/yii2-coding-standards": "~2.0", - "cweagans/composer-patches": "^1.7", - "phpunit/phpunit": "4.8.34" + "phpunit/phpunit": "^9.6" }, "autoload": { "psr-4": { @@ -44,20 +44,6 @@ "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": { @@ -66,7 +52,6 @@ "enabled": false }, "allow-plugins": { - "cweagans/composer-patches": true, "yiisoft/yii2-composer": true } }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a2bff8953..468eca362 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,27 @@ - - - - ./tests - - + + + + + + + + + ./tests + + + + + + ./src + + diff --git a/tests/GiiTestCase.php b/tests/GiiTestCase.php index f390ee6ea..e5138186e 100644 --- a/tests/GiiTestCase.php +++ b/tests/GiiTestCase.php @@ -13,7 +13,7 @@ class GiiTestCase extends TestCase { protected $driverName = 'sqlite'; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -49,4 +49,4 @@ protected function setUp() } } } -} \ No newline at end of file +} diff --git a/tests/TestCase.php b/tests/TestCase.php index e6d111520..fda7843de 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,7 +15,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/bootstrap.php b/tests/bootstrap.php index a9b8059a4..a9dd30f9c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,5 +13,3 @@ Yii::setAlias('@yiiunit/gii', __DIR__); Yii::setAlias('@yii/gii', dirname(__DIR__) . '/src'); - -require_once(__DIR__ . '/compatibility.php'); \ No newline at end of file diff --git a/tests/compatibility.php b/tests/compatibility.php deleted file mode 100644 index d27c0ef1c..000000000 --- a/tests/compatibility.php +++ /dev/null @@ -1,37 +0,0 @@ -setExpectedException($exception); - } - - /** - * @param string $message - */ - public function expectExceptionMessage($message) - { - $this->setExpectedException($this->getExpectedException(), $message); - } - } - } -}