Skip to content

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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
71 changes: 28 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,32 @@
name: build
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

on: [push, pull_request]
push:
branches: ['master']
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']
31 changes: 31 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
checks:
php: true

filter:
paths:
- src/

build:
image: default-bionic

environment:
php:
version: 8.0.18
ini:
xdebug.mode: coverage

nodes:
analysis:
tests:
override:
- php-scrutinizer-run

phpunit:
dependencies:
override:
- composer self-update
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

tests:
override:
- command: ./vendor/bin/phpunit
18 changes: 3 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
}
],
"require": {
"yiisoft/yii2": "~2.0.13",
"paragonie/random_compat": ">=1"
"php": ">=7.3",
"yiisoft/yii2": "~2.0.13"
},
"require-dev": {
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
"phpunit/phpunit": "^9.6"
},
"repositories": [
{
Expand All @@ -33,7 +32,6 @@
],
"config": {
"allow-plugins": {
"cweagans/composer-patches": true,
"yiisoft/yii2-composer": true
}
},
Expand All @@ -43,16 +41,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/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"
}
}
}
}
4 changes: 2 additions & 2 deletions tests/CurlFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class CurlFormatterTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
Expand Down Expand Up @@ -52,7 +52,7 @@ public function testFormatMethodGet()
$formatter = new CurlFormatter();
$formatter->format($request);
$this->assertEmpty($request->getContent());
$this->assertContains(http_build_query($data), $request->getFullUrl());
$this->assertStringContainsString(http_build_query($data), $request->getFullUrl());
$this->assertFalse($request->getHeaders()->has('Content-Type'));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/MockTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class MockTransportTest extends TestCase
*/
private $transport;

protected function setUp()
protected function setUp(): void
{
$this->transport = new MockTransport();
$this->client = new Client(['transport' => $this->transport]);
Expand Down
6 changes: 3 additions & 3 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class RequestTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
Expand Down Expand Up @@ -216,8 +216,8 @@ public function testToString()
$request->addFileContent('some-file', 'some content');

$result = $request->toString();
$this->assertContains('Content-Type: multipart/form-data; boundary=', $result);
$this->assertContains('some content', $result);
$this->assertStringContainsString('Content-Type: multipart/form-data; boundary=', $result);
$this->assertStringContainsString('some content', $result);
}

/**
Expand Down
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
17 changes: 8 additions & 9 deletions tests/TransportTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
abstract class TransportTestCase extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
Expand Down Expand Up @@ -49,7 +49,7 @@ public function testSend()
$this->assertResponseIsOK($response);
$content = $response->getContent();
$this->assertNotEmpty($content);
$this->assertContains('<h1>Documentation</h1>', $content);
$this->assertStringContainsString('<h1>Documentation</h1>', $content);
}

/**
Expand Down Expand Up @@ -90,11 +90,10 @@ public function testBatchSend()
$this->assertResponseIsOK($response);
}

$this->assertTrue($responses['docs'] instanceof Response, $responses);
$this->assertTrue($responses['support'] instanceof Response, $responses);

$this->assertContains('<h1>Documentation</h1>', $responses['docs']->getContent());
$this->assertContains('Mailing Lists', $responses['support']->getContent());
$this->assertInstanceOf(Response::class, $responses['docs']);
$this->assertInstanceOf(Response::class, $responses['support']);
$this->assertStringContainsString('<h1>Documentation</h1>', $responses['docs']->getContent());
$this->assertStringContainsString('Mailing Lists', $responses['support']->getContent());
}

/**
Expand Down Expand Up @@ -305,6 +304,6 @@ public function testCustomSslCertificate()
$this->assertResponseIsOK($response);
$content = $response->getContent();
$this->assertNotEmpty($content);
$this->assertContains('<h1>Documentation</h1>', $content);
$this->assertStringContainsString('<h1>Documentation</h1>', $content);
}
}
}
4 changes: 2 additions & 2 deletions tests/UrlEncodedFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class UrlEncodedFormatterTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
Expand Down Expand Up @@ -47,7 +47,7 @@ public function testFormatMethodGet()
$formatter = new UrlEncodedFormatter();
$formatter->format($request);
$this->assertEmpty($request->getContent());
$this->assertContains(http_build_query($data), $request->getFullUrl());
$this->assertStringContainsString(http_build_query($data), $request->getFullUrl());
$this->assertFalse($request->getHeaders()->has('Content-Type'));
}

Expand Down
4 changes: 2 additions & 2 deletions tests/XmlFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class XmlFormatterTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
Expand Down Expand Up @@ -194,4 +194,4 @@ public function toArray(array $fields = [], array $expand = [], $recursive = tru
{
return ['name1' => 'value1'];
}
}
}
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/httpclient', __DIR__);
Yii::setAlias('@yii/httpclient', dirname(__DIR__) . '/src');

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

This file was deleted.