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

PHP 8.0 + Move to Actions + Fix deprecations + Refactor #28

Merged
merged 1 commit into from
Dec 8, 2021
Merged
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
129 changes: 129 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: CI

on:
pull_request:
branches:
- "*.*"
- master
push:
branches:
- "*.*"
- master

jobs:
tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php-version:
- '8.0'
- '8.1'
symfony-version:
- '5.3.*'
- '5.4.*'
- '6.0.*'
dependencies:
- 'lowest'
- 'highest'
remove-dependencies: [ '' ]
coverage: [ 'none' ]
include:
- php-version: '8.0'
symfony-version: '5.3.*'
dependencies: 'lowest'
remove-dependencies: '--dev symfony/validator doctrine/orm doctrine/annotations'
- php-version: '8.0'
symfony-version: '5.3.*'
dependencies: 'lowest'
coverage: "pcov"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
tools: flex
php-version: "${{ matrix.php-version }}"
coverage: "${{ matrix.coverage }}"

- name: "Change stability"
if: "matrix.stability != ''"
run: perl -pi -e 's/^}$/,"minimum-stability":"'"${{ matrix.minimum-stability }}"'"}/' composer.json && cat composer.json

- name: "Webonyx GraphQL version"
if: "matrix.graphql-version != ''"
run: composer require "webonyx/graphql-php:${{ matrix.graphql-version }}" --dev --no-update

- name: Remove dependencies
if: "matrix.remove-dependencies != ''"
run: composer remove --no-update ${{ matrix.remove-dependencies }}

- name: "Install dependencies"
uses: ramsey/[email protected]
with:
dependency-versions: ${{ matrix.dependencies }}
env:
SYMFONY_REQUIRE: "${{ matrix.symfony-version }}"

- name: "Run tests"
run: composer test

- name: "Upload coverage results to Coveralls"
if: "matrix.coverage == 'pcov'"
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.1/php-coveralls.phar
php php-coveralls.phar --coverage_clover=build/logs/clover.xml -v
coding-standard:
runs-on: ubuntu-20.04
name: Coding Standard
steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
tools: flex
php-version: "8.0"

- name: "Install dependencies"
uses: ramsey/[email protected]

- name: "Check coding standard"
run: composer check-cs

static-analysis:
runs-on: ubuntu-20.04
name: "Static analysis"
strategy:
fail-fast: false
matrix:
php-version:
- '8.0'
- '8.1'
steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ matrix.php-version }}
coverage: "none"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Install dependencies"
uses: ramsey/[email protected]

- name: "Run static-analysis"
run: composer static-analysis
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ phpunit.xml
composer.lock
composer.phar
.php_cs.cache
/.phpunit.result.cache
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Tests/DependencyInjection/OverblogDataLoaderExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public function testValidServiceCallableNodeValue()
{
$validValues = ['@app.user:getUsers', '@App\\Loader\\User:all'];
foreach ($validValues as $validValue) {
$this->assertRegExp(Configuration::SERVICE_CALLABLE_NOTATION_REGEX, $validValue);
$this->assertMatchesRegularExpression(Configuration::SERVICE_CALLABLE_NOTATION_REGEX, $validValue);
}
}

public function testValidPhpCallableNodeValue()
{
$validValues = ['Image\\Loader::get', 'Post::getPosts'];
foreach ($validValues as $validValue) {
$this->assertRegExp(Configuration::PHP_CALLABLE_NOTATION_REGEX, $validValue);
$this->assertMatchesRegularExpression(Configuration::PHP_CALLABLE_NOTATION_REGEX, $validValue);
}
}

Expand Down Expand Up @@ -152,7 +152,7 @@ public function testImagesDataLoaderConfig()
public function testBatchLoadFnNotCallable()
{
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid configuration for path "overblog_dataloader.loaders.users.batch_load_fn": "this is not a callable" doesn\'t seem to be a valid callable.');
$this->expectExceptionMessage("\"NOT CALLABLE\" doesn't seem to be a valid callable.");

$this->extension->load(
[
Expand All @@ -162,7 +162,7 @@ public function testBatchLoadFnNotCallable()
],
'loaders' => [
'users' => [
'batch_load_fn' => 'this is not a callable',
'batch_load_fn' => 'NOT CALLABLE',
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/BootTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class BootTest extends TestCase
{
public function testBootAppKernel()
public function testBootAppKernel(): void
{
$kernel = $this->createKernel();
$kernel->boot();
Expand Down
12 changes: 8 additions & 4 deletions Tests/Functional/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,34 @@

use Overblog\DataLoaderBundle\Tests\Functional\app\AppKernel;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* TestCase.
*/
abstract class TestCase extends WebTestCase
{
protected static function getKernelClass()
protected static function getKernelClass(): string
{
require_once __DIR__.'/app/AppKernel.php';

return AppKernel::class;
}

/**
* {@inheritdoc}
*/
protected static function createKernel(array $options = [])
protected static function createKernel(array $options = []): KernelInterface
{
if (null === static::$class) {
static::$class = static::getKernelClass();
}

$options['test_case'] = isset($options['test_case']) ? $options['test_case'] : null;

$env = isset($options['environment']) ? $options['environment'] : 'test'.strtolower($options['test_case']);
$env = isset($options['environment']) ? $options['environment'] : 'test'.strtolower($options['test_case'] ?? '');
$debug = isset($options['debug']) ? $options['debug'] : true;

return new static::$class($env, $debug, $options['test_case']);
Expand All @@ -51,7 +55,7 @@ public static function setUpBeforeClass(): void
$fs->remove(sys_get_temp_dir().'/OverblogDataLoaderBundle/');
}

protected static function getContainer()
protected static function getContainer(): ContainerInterface
{
return static::$kernel->getContainer();
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/Functional/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ class AppKernel extends Kernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): array
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Overblog\DataLoaderBundle\OverblogDataLoaderBundle(),
];
}

public function getCacheDir()
public function getCacheDir(): string
{
return sys_get_temp_dir().'/OverblogDataLoaderBundle/'.Kernel::VERSION.'/cache/'.$this->environment;
}

public function getLogDir()
public function getLogDir(): string
{
return sys_get_temp_dir().'/OverblogDataLoaderBundle/'.Kernel::VERSION.'/logs';
}
Expand All @@ -57,6 +57,6 @@ public function isBooted()
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.yml');
$loader->load(__DIR__.'/config/config.yaml');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ framework:
test: ~
secret: test
router:
resource: "%kernel.project_dir%/config/routing.yml"
resource: "%kernel.project_dir%/config/routing.yaml"
profiler:
enabled: false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
overblog_graphql_endpoint:
resource: "@OverblogDataLoaderBundle/Resources/config/routing/graphql.yml"
resource: "@OverblogDataLoaderBundle/Resources/config/routing/graphql.yaml"

overblog_graphql_graphiql:
resource: "@OverblogDataLoaderBundle/Resources/config/routing/graphiql.yml"
resource: "@OverblogDataLoaderBundle/Resources/config/routing/graphiql.yaml"
27 changes: 14 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@
],
"autoload": {
"psr-4": {
"Overblog\\DataLoaderBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
"Overblog\\DataLoaderBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Overblog\\DataLoaderBundle\\Tests\\": "tests/"
}
},
"config" : {
"bin-dir": "bin",
"sort-packages": true
},
"require": {
"php": ">=7.2",
"overblog/dataloader-php": "^0.5.0 || ^0.6.0",
"symfony/dependency-injection": "^4.3 || ^5.0"
"php": "^8.0",
"overblog/dataloader-php": "^0.7.0",
"symfony/dependency-injection": "^5.3 || ^6.0"
},
"require-dev": {
"phpunit/phpunit": "^4.1 || ^5.5 || ^6.5 || ^7.5 || ^8.5",
"phpunit/phpunit": "^9.5.10",
"react/promise": "^2.5",
"symfony/dependency-injection": "^4.3 || ^5.0",
"symfony/framework-bundle": "^4.3 || ^5.0",
"symfony/phpunit-bridge": "^4.3 || ^5.0",
"symfony/yaml": "^4.3 || ^5.0"
"sensio/framework-extra-bundle": "^6.2",
"symfony/phpunit-bridge": "^6.0",
"symfony/yaml": "^5.3 || ^6.0"
},
"extra": {
"branch-alias": {
Expand Down
11 changes: 0 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

<php>
<ini name="error_reporting" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="999999" />
Expand Down
Loading