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. #379

Draft
wants to merge 2 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
69 changes: 27 additions & 42 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:
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']
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']

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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Documentation is at [docs/guide/README.md](https://github.com/yiisoft/yii2-authc
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-authclient/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-authclient)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-authclient/downloads.png)](https://packagist.org/packages/yiisoft/yii2-authclient)
[![Build Status](https://github.com/yiisoft/yii2-authclient/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-authclient/actions)
[![codecov](https://codecov.io/gh/yiisoft/yii2-authclient/graph/badge.svg?token=2WagT7dB3K)](https://codecov.io/gh/yiisoft/yii2-authclient)

Requirements
------------

- PHP 7.3 or higher.

Installation
------------
Expand Down
17 changes: 3 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
}
],
"require": {
"php": ">=7.3",
"yiisoft/yii2": "~2.0.13",
"yiisoft/yii2-httpclient": "~2.0.5",
"paragonie/random_compat": ">=1"
"yiisoft/yii2-httpclient": "~2.0.5"
},
"require-dev": {
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
"phpunit/phpunit": "^9.6"
},
"suggest": {
"web-token/jwt-checker": "required for JWS, JWT or JWK related flows like OpenIDConnect",
Expand All @@ -49,20 +48,10 @@
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
},
"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": {
"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-AuthClient">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions tests/AuthActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AuthActionTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$config = [
'components' => [
Expand Down Expand Up @@ -65,7 +65,7 @@ public function testRedirect()
$url = 'http://test.url';
$response = $action->redirect($url, true);

$this->assertContains($url, $response->content);
$this->assertStringContainsString($url, $response->content);
}

public function testGetClientId()
Expand Down
4 changes: 2 additions & 2 deletions tests/BaseClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class BaseClientTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
Expand Down Expand Up @@ -227,4 +227,4 @@ public function testSetupStateStorage()
$stateStorage = $client->getStateStorage();
$this->assertTrue($stateStorage instanceof SessionStateStorage, 'Unable to get default http client.');
}
}
}
4 changes: 2 additions & 2 deletions tests/BaseOAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BaseOAuthTest extends TestCase
{
use OAuthDefaultReturnUrlTestTrait;

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

Expand Down Expand Up @@ -241,7 +241,7 @@ public function testSendRequest($responseStatusCode, $expectedException)
$response->addHeaders(['http-code' => $responseStatusCode]);
$response->setData('success');

$request = $this->getMock(Request::className());
$request = $this->createMock(Request::className());
$request
->expects($this->any())
->method('send')
Expand Down
6 changes: 3 additions & 3 deletions tests/OAuth1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class OAuth1Test extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$config = [
'components' => [
Expand Down Expand Up @@ -178,7 +178,7 @@ public function testBuildAuthUrl()

$builtAuthUrl = $oauthClient->buildAuthUrl($requestToken);

$this->assertContains($authUrl, $builtAuthUrl, 'No auth URL present!');
$this->assertContains($requestTokenToken, $builtAuthUrl, 'No token present!');
$this->assertStringContainsString($authUrl, $builtAuthUrl, 'No auth URL present!');
$this->assertStringContainsString($requestTokenToken, $builtAuthUrl, 'No token present!');
}
}
12 changes: 6 additions & 6 deletions tests/OAuth2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class OAuth2Test extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$config = [
'components' => [
Expand Down Expand Up @@ -45,9 +45,9 @@ public function testBuildAuthUrl()

$builtAuthUrl = $oauthClient->buildAuthUrl();

$this->assertContains($authUrl, $builtAuthUrl, 'No auth URL present!');
$this->assertContains($clientId, $builtAuthUrl, 'No client id present!');
$this->assertContains(rawurlencode($returnUrl), $builtAuthUrl, 'No return URL present!');
$this->assertStringContainsString($authUrl, $builtAuthUrl, 'No auth URL present!');
$this->assertStringContainsString($clientId, $builtAuthUrl, 'No client id present!');
$this->assertStringContainsString(rawurlencode($returnUrl), $builtAuthUrl, 'No return URL present!');
}

public function testPkceCodeChallengeIsPresentInAuthUrl()
Expand All @@ -61,7 +61,7 @@ public function testPkceCodeChallengeIsPresentInAuthUrl()

$builtAuthUrl = $oauthClient->buildAuthUrl();

$this->assertContains('code_challenge=', $builtAuthUrl, 'No code challenge Present!');
$this->assertContains('code_challenge_method=S256', $builtAuthUrl, 'No code challenge method Present!');
$this->assertStringContainsString('code_challenge=', $builtAuthUrl, 'No code challenge Present!');
$this->assertStringContainsString('code_challenge_method=S256', $builtAuthUrl, 'No code challenge method Present!');
}
}
6 changes: 3 additions & 3 deletions tests/OpenIdConnectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class OpenIdConnectTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$config = [
'components' => [
Expand Down Expand Up @@ -85,8 +85,8 @@ public function testBuildAuthUrl()
$builtAuthUrl = $authClient->buildAuthUrl();

$this->assertNotEmpty($authClient->authUrl);
$this->assertContains($clientId, $builtAuthUrl, 'No client id present!');
$this->assertContains(rawurlencode($returnUrl), $builtAuthUrl, 'No return URL present!');
$this->assertStringContainsString($clientId, $builtAuthUrl, 'No client id present!');
$this->assertStringContainsString(rawurlencode($returnUrl), $builtAuthUrl, 'No return URL present!');
}

public function testNonce()
Expand Down
2 changes: 1 addition & 1 deletion tests/OpenIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class OpenIdTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$config = [
'components' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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: 1 addition & 1 deletion tests/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testCreateWithIncorrectConfigOrder()
'tokenSecretParamKey' => 'test_token_secret_param_key',
];
$oauthToken = new OAuthToken($config);
$this->assertInternalType('object', $oauthToken, 'Unable to create access token!');
$this->assertIsObject($oauthToken, 'Unable to create access token!');
foreach ($config as $name => $value) {
$this->assertEquals($value, $oauthToken->$name, 'Unable to setup attributes by constructor!');
}
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/authclient', __DIR__);
Yii::setAlias('@yii/authclient', dirname(__DIR__) . '/src');

require_once(__DIR__ . '/compatibility.php');
2 changes: 1 addition & 1 deletion tests/clients/GoogleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GoogleTest extends TestCase
{
use OAuthDefaultReturnUrlTestTrait;

protected function setUp()
protected function setUp(): void
{
$config = [
'components' => [
Expand Down
32 changes: 0 additions & 32 deletions tests/compatibility.php

This file was deleted.