Skip to content

Commit

Permalink
Raise min PHP version to PHP 7.3, check compatibility PHP 8.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Oct 5, 2023
1 parent 4e65aca commit d31b334
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 130 deletions.
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
73 changes: 30 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,34 @@
name: build
on:
fork:

on: [push, pull_request]
pull_request:
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"
push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

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']
name: build

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
jobs:
phpunit:
if: github.event.repository.fork == true || (github.event_name == 'push' && github.ref == 'refs/heads/master')
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']
22 changes: 8 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
}
],
"require": {
"yiisoft/yii2": "~2.0.4",
"bower-asset/jquery-ui": "~1.12.1"
"bower-asset/jquery-ui": "~1.12.1",
"yiisoft/yii2": "~2.0.4"
},
"require-dev": {
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
"phpunit/phpunit": "^9.6"
},
"repositories": [
{
Expand All @@ -51,16 +50,11 @@
"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": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
}
}
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-Jui">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
6 changes: 3 additions & 3 deletions tests/DatePickerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function testLanguageAsset()
]);

// https://github.com/yiisoft/yii2-jui/issues/6
static::assertRegExp(
$this->assertMatchesRegularExpression(
'~<script src="/assets/[0-9a-f]+/ui/i18n/datepicker-ru.js\?v=\d+"></script>~',
$out,
'There should be language asset registered with timestamp appended.'
'There should be language asset registered with timestamp appended.',
);
}

Expand Down Expand Up @@ -79,6 +79,6 @@ public function testInvalidDateValue($value)
'value' => $value
]);
$output = ob_get_clean();
$this->assertContains($value, $output);
$this->assertStringContainsString($value, $output);
}
}
10 changes: 6 additions & 4 deletions tests/SelectableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ public function testBeginEnd()
]);

// https://github.com/yiisoft/yii2-jui/issues/46
static::assertRegExp(
$this->assertMatchesRegularExpression(
'~<div id="myselectableitems">\n<ul>\n<li class="myselectableitem">Item 1</li>\n<li class="myselectableitem">Item 2</li>\n<li class="noselectableitem">Item 3</li>\n<li class="myselectableitem">Item 4</li>\n</ul>\n<div>\n<div>\n<div class="myselectableitem">Another item</div>\n</div>\n</div></div>~',
$out,
'There should be a div with class myselectableitems enclosing html between begin()` and `end()` methods');
static::assertRegExp(
'There should be a div with class myselectableitems enclosing html between begin()` and `end()` methods',
);
$this->assertMatchesRegularExpression(
'~<script>jQuery\(function \(\$\) \{\njQuery\(\'#myselectableitems\'\)\.selectable\(\{\"filter"\:"myselectableitem","tolerance"\:"touch"\}\);\n\}\);</script>~',
$out,
'There should be the jQuery UI Selectable plugin initialization for myselectableitems');
'There should be the jQuery UI Selectable plugin initialization for myselectableitems',
);
}
}
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
abstract class TestCase extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->mockWebApplication();
Expand All @@ -21,7 +21,7 @@ protected function setUp()
* 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/extensions/jui', __DIR__);
Yii::setAlias('@yii/jui', dirname(__DIR__) . '/src');

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

This file was deleted.

0 comments on commit d31b334

Please sign in to comment.