Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise min version to PHP 7.3, check compatibility PHP 8.3. #536

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
139 changes: 74 additions & 65 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 "<?php unset(\$config['databases']['pgsql']['fixture']);" > 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 "<?php unset(\$config['databases']['pgsql']['fixture']);" > 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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand Down
19 changes: 2 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -66,7 +52,6 @@
"enabled": false
},
"allow-plugins": {
"cweagans/composer-patches": true,
"yiisoft/yii2-composer": true
}
},
Expand Down
37 changes: 25 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./tests/bootstrap.php"
colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>

<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Yii2-Gii">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions tests/GiiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GiiTestCase extends TestCase
{
protected $driverName = 'sqlite';

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -49,4 +49,4 @@ protected function setUp()
}
}
}
}
}
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@

Yii::setAlias('@yiiunit/gii', __DIR__);
Yii::setAlias('@yii/gii', dirname(__DIR__) . '/src');

require_once(__DIR__ . '/compatibility.php');
37 changes: 0 additions & 37 deletions tests/compatibility.php

This file was deleted.