Skip to content

Commit

Permalink
Merge pull request #21 from mpdude/mpdude-changes
Browse files Browse the repository at this point in the history
Updates, deprecation fixes and GitHub Actions CI setup
  • Loading branch information
jbouzekri committed May 8, 2022
2 parents b3dec51 + fa171c9 commit dbf28c6
Show file tree
Hide file tree
Showing 24 changed files with 122 additions and 60 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Dependencies

permissions:
contents: read

on:
push:
branches:
- master
pull_request:

env:
PHP_VERSION: 7.4

jobs:
composer-require-checker:
name: Check missing composer requirements
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:v2
- uses: actions/checkout@v3
- uses: actions/cache@v2
with:
path: vendor
key: composer-${{ runner.os }}-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-${{ runner.os }}-${{ env.PHP_VERSION }}-
composer-${{ runner.os }}-
- run: |
composer install --no-interaction --no-progress --ansi --no-scripts
composer show
- uses: docker://webfactory/composer-require-checker:3.2.0
3 changes: 3 additions & 0 deletions .github/workflows/lock-symfony-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

cat <<< $(jq --arg version $VERSION '.require |= with_entries(if ((.key|test("^symfony/service-contracts")|not) and (.key|test("^symfony/"))) then .value=$version else . end)' < composer.json) > composer.json
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on:
push:
branches:
- master
pull_request:

env:
SYMFONY_DEPRECATIONS_HELPER: weak

jobs:
PHPUnit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { php-version: 7.2, symfony-locked-version: none, dependency-version: prefer-lowest }
- { php-version: 7.4, symfony-locked-version: 4.4.*, dependency-version: prefer-stable }
- { php-version: 8.1, symfony-locked-version: 5.4.*, dependency-version: prefer-stable }
- { php-version: 8.1, symfony-locked-version: none, dependency-version: prefer-stable }
name: PHPUnit (PHP ${{matrix.php-version}}, Symfony Version Lock ${{ matrix.symfony-locked-version }}, ${{ matrix.dependency-version }})
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
- uses: actions/checkout@v3
- run: VERSION=${{ matrix.symfony-locked-version }} .github/workflows/lock-symfony-version.sh
if: matrix.symfony-locked-version != 'none'
- uses: actions/cache@v2
with:
path: vendor
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-
- run: |
composer update --no-interaction --no-progress --ansi --no-scripts --${{ matrix.dependency-version}}
composer show
- run: vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ before_script:
- wget https://scrutinizer-ci.com/ocular.phar

script:
- vendor/bin/phpunit -c Tests/ --coverage-clover=coverage.clover
- vendor/bin/phpunit --coverage-clover=coverage.clover
- phpcs --standard=PSR2 --extensions=php --ignore=vendor .
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
14 changes: 0 additions & 14 deletions Tests/bootstrap.php

This file was deleted.

25 changes: 14 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{
"name": "jbouzekri/phumbor-bundle",
"type": "symfony-bundle",
"description": "A bridge for symfony with the phumbor client from 99designs",
"description": "A Symfony Bundle to use the minimal Thumbor PHP client from webfactory/phumbor",
"keywords": ["phumbor", "thumbor", "Bundle", "Helper", "Twig", "Symfony"],
"homepage": "https://github.com/jbouzekri/PhumborBundle",
"license": "MIT",
"require": {
"php": "^7.2|8.0.*|8.1.*",
"symfony/config": "^3.4|^4.4|^5.0|^6.0",
"symfony/dependency-injection": "^3.4|^4.4|^5.0|^6.0",
"symfony/http-kernel": "^3.4|^4.4|^5.0|^6.0",
"twig/twig": "^1.34|^2.0|^3.0",
"webfactory/phumbor": "^1.1"
},
"require-dev": {
"symfony/config": "^3.4",
"symfony/dependency-injection": "^3.4",
"symfony/http-kernel": "^3.4",
"symfony/yaml": "^3.4",
"phpunit/phpunit": "^7.0",
"twig/extensions": "~1.0"
},
"conflict": {
"twig/twig": "<1.34"
"phpunit/phpunit": "^8.5.26|^9.5.20",
"symfony/yaml": "^3.4|^4.4|^5.0|^6.0",
"twig/extensions": "~1.0",
"symfony/phpunit-bridge": ">=6.0"
},
"autoload": {
"psr-4": { "Jb\\Bundle\\PhumborBundle\\": "" }
"psr-4": { "Jb\\Bundle\\PhumborBundle\\": "src" }
},
"autoload-dev": {
"psr-4": { "Jb\\Bundle\\PhumborBundle\\Tests\\": "tests" }
}
}
14 changes: 6 additions & 8 deletions Tests/phpunit.xml.dist → phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="bootstrap.php"
bootstrap="vendor/autoload.php"
>

<testsuites>
<testsuite name="TestBundle Test Suite">
<directory>.</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">.</directory>
<exclude>
<directory>vendor</directory>
<directory>Tests</directory>
</exclude>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ class Configuration implements ConfigurationInterface
{
/**
* Generates the configuration tree builder.
*
* @return TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
if (Kernel::VERSION_ID >= 40200) {
$treeBuilder = new TreeBuilder('jb_phumbor');
Expand Down Expand Up @@ -51,8 +49,6 @@ public function getConfigTreeBuilder()

/**
* Add the transformation section configuration structure
*
* @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode
*/
private function addTransformationSection(ArrayNodeDefinition $rootNode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class JbPhumborExtension extends Extension
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration(new Configuration(), $configs);
$this->loadConfiguration($container, $config);
Expand All @@ -32,7 +32,7 @@ public function load(array $configs, ContainerBuilder $container)
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param array $config
*/
protected function loadConfiguration(ContainerBuilder $container, array $config)
protected function loadConfiguration(ContainerBuilder $container, array $config): void
{
$container->setParameter('env(THUMBOR_URL)', 'http://localhost:8888');
$container->setParameter('env(THUMBOR_SECURITY_KEY)', '');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BaseTransformer
/**
* Phumbor Builder Factory
*
* @var \Thumbor\Url\BuilderFactory
* @var BuilderFactory
*/
protected $factory;

Expand All @@ -44,12 +44,6 @@ class BaseTransformer
*/
protected $transformations;

/**
* Constructor
*
* @param \Thumbor\Url\BuilderFactory $factory
* @param array $transformations
*/
public function __construct(BuilderFactory $factory, array $transformations)
{
$this->factory = $factory;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions Twig/PhumborExtension.php → src/Twig/PhumborExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(BaseTransformer $transformer)
/**
* {@inheritDoc}
*/
public function getFilters()
public function getFilters(): array
{
return array(
new TwigFilter('thumbor', array($this, 'transform')),
Expand All @@ -42,7 +42,7 @@ public function getFilters()
/**
* {@inheritDoc}
*/
public function getFunctions()
public function getFunctions(): array
{
return array(
new TwigFunction('thumbor', array($this, 'transform')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
namespace Jb\Bundle\PhumborBundle\Tests\DependencyInjection;

use Jb\Bundle\PhumborBundle\DependencyInjection\Configuration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\Processor;

/**
* Test configuration
*
* @author Jonathan Bouzekri <[email protected]>
*/
class ConfigurationTest extends \PHPUnit_Framework_TestCase
class ConfigurationTest extends TestCase
{
/**
* Test the default configuration
Expand Down Expand Up @@ -135,11 +137,12 @@ public function getTransformationData()
}

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @dataProvider getInvalidTypeData
*/
public function testInvalidType($transformationData)
{
self::expectException(InvalidConfigurationException::class);

$processor = new Processor();
$configuration = new Configuration();
$processor->processConfiguration($configuration, array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jb\Bundle\PhumborBundle\Tests\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Jb\Bundle\PhumborBundle\DependencyInjection\JbPhumborExtension;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
Expand All @@ -11,7 +12,7 @@
*
* @author Jonathan Bouzekri <[email protected]>
*/
abstract class JbPhumborExtensionTest extends \PHPUnit_Framework_TestCase
abstract class JbPhumborExtensionTest extends TestCase
{
/**
* Defined in children class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jb\Bundle\PhumborBundle\Tests\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
namespace Jb\Bundle\PhumborBundle\Tests\Transformer;

use Jb\Bundle\PhumborBundle\Transformer\BaseTransformer;
use Jb\Bundle\PhumborBundle\Transformer\Exception\UnknownTransformationException;
use PHPUnit\Framework\TestCase;
use Thumbor\Url\BuilderFactory;

/**
* Description of BaseTransformerTest
*
* @author jobou
*/
class BaseTransformerTest extends \PHPUnit_Framework_TestCase
class BaseTransformerTest extends TestCase
{
/**
* @var \Jb\Bundle\PhumborBundle\Transformer\BaseTransformer
Expand All @@ -25,7 +27,7 @@ class BaseTransformerTest extends \PHPUnit_Framework_TestCase
/**
* SetUp
*/
public function setUp()
public function setUp(): void
{
$this->factory = new BuilderFactory('http://localhost', '123456789');
$this->transformer = new BaseTransformer(
Expand Down Expand Up @@ -60,11 +62,9 @@ public function testNormalTransformation()
$this->assertEquals($transformedUrl, $buildedUrl);
}

/**
* @expectedException \Jb\Bundle\PhumborBundle\Transformer\Exception\UnknownTransformationException
*/
public function testUnknownTransformationException()
{
self::expectException(UnknownTransformationException::class);
$transformedUrl = $this->transformer->transform('http://phumbor.jb.fr/logo.png', 'not_known');
$buildedUrl = $this->factory->url('http://phumbor.jb.fr/logo.png');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

use Jb\Bundle\PhumborBundle\Twig\PhumborExtension;
use Jb\Bundle\PhumborBundle\Transformer\BaseTransformer;
use PHPUnit\Framework\TestCase;
use Thumbor\Url\BuilderFactory;

/**
* Description of PhumborExtensionTest
*
* @author jobou
*/
class PhumborExtensionTest extends \PHPUnit_Framework_TestCase
class PhumborExtensionTest extends TestCase
{
/**
* @var \Jb\Bundle\PhumborBundle\Twig\PhumborExtension
Expand All @@ -26,7 +27,7 @@ class PhumborExtensionTest extends \PHPUnit_Framework_TestCase
/**
* SetUp
*/
public function setUp()
public function setUp(): void
{
$this->factory = new BuilderFactory('http://localhost', '123456789');
$transformer = new BaseTransformer(
Expand Down

0 comments on commit dbf28c6

Please sign in to comment.