Skip to content

Commit

Permalink
Merge pull request #93 from sorrx/master
Browse files Browse the repository at this point in the history
support Symfony 7
  • Loading branch information
dontub authored Mar 16, 2024
2 parents 88d8fe0 + 3f8bc83 commit de3b1d7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@ jobs:
strategy:
matrix:
# Earliest and latest version of each major version
php-versions: ['7.2', '7.4', '8.0', '8.2']
php-versions: ['7.2', '7.4', '8.0', '8.3']
prefer: ['prefer-stable', 'prefer-lowest']
symfony-versions: ['^3.4', '^4', '^5', '^6']
symfony-versions: ['^5.4', '^6', '^7']
include:
- symfony-versions: '^3.4'
symfony-bundle-test-version: '^1.8'
- symfony-versions: '^7'
symfony7-required-yaml-version: '^6 || ^7'
exclude:
# Symfony 7 requires at least PHP 8.2
- php-versions: '7.2'
symfony-versions: '^7'
- php-versions: '7.4'
symfony-versions: '^7'
- php-versions: '8.0'
symfony-versions: '^7'
# Symfony 6 requires PHP 8
- php-versions: '7.2'
symfony-versions: '^6'
- php-versions: '7.4'
symfony-versions: '^6'
# Symfony 3.4 with PHP 8 is possible, though we skip it to reduce the number of jobs
- php-versions: '8.0'
symfony-versions: '^3.4'
- php-versions: '8.1'
symfony-versions: '^3.4'
name: Test PHP ${{ matrix.php-versions }}, Symfony ${{ matrix.symfony-versions }}, ${{ matrix.prefer }}

steps:
Expand All @@ -53,12 +55,12 @@ jobs:

- name: Install dependencies
run: |
if [ -n "${{ matrix.symfony-bundle-test-version }}" ]; then
composer require --dev --no-update "nyholm/symfony-bundle-test:${{ matrix.symfony-bundle-test-version }}"
fi
for symfony_package in $(jq -r '.require | keys[]' composer.json | grep '^symfony/'); do
composer require --no-update "${symfony_package}:${{ matrix.symfony-versions }}"
done
if [ -n "${{ matrix.symfony7-required-yaml-version }}" ]; then
composer require --dev --no-update "symfony/yaml:${{ matrix.symfony7-required-yaml-version }}"
fi
composer --prefer-dist --${{ matrix.prefer }} update
- name: Setup problem matchers for PHPUnit
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
"wiki": "https://github.com/shivas/versioning-bundle/wiki"
},
"require": {
"php": "^7.2 || ^8",
"php": "^7.2.5 || ^8",
"nikolaposa/version": "^4",
"symfony/console": "^3.4 || ^4 || ^5 || ^6",
"symfony/framework-bundle": "^3.4 || ^4 || ^5 || ^6",
"symfony/process": "^3.4 || ^4 || ^5 || ^6"
"symfony/console": "^5.4 || ^6 || ^7",
"symfony/framework-bundle": "^5.4 || ^6 || ^7",
"symfony/process": "^5.4 || ^6 || ^7"
},
"require-dev": {
"mikey179/vfsstream": "^2",
"nyholm/symfony-bundle-test": "1.x-dev",
"nyholm/symfony-bundle-test": "^3.0",
"phpunit/phpunit": "^8.5.27",
"symfony/phpunit-bridge": "^5 || ^6",
"symfony/phpunit-bridge": "^5.4 || ^6 || ^7",
"twig/twig": "^2 || ^3"
},
"config": {
Expand Down
31 changes: 22 additions & 9 deletions tests/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

namespace Shivas\VersioningBundle\Tests;

use Nyholm\BundleTest\BaseBundleTestCase;
use Nyholm\BundleTest\CompilerPass\PublicServicePass;
use Nyholm\BundleTest\TestKernel;
use Shivas\VersioningBundle\Formatter\FormatterInterface;
use Shivas\VersioningBundle\Formatter\GitDescribeFormatter;
use Shivas\VersioningBundle\Provider\GitRepositoryProvider;
Expand All @@ -17,22 +16,36 @@
use Shivas\VersioningBundle\Twig\VersionExtension;
use Shivas\VersioningBundle\Writer\VersionWriter;
use Shivas\VersioningBundle\Writer\WriterInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* @covers \Shivas\VersioningBundle\ShivasVersioningBundle
*/
class BundleInitializationTest extends BaseBundleTestCase
class BundleInitializationTest extends KernelTestCase
{
protected function setUp(): void
protected static function getKernelClass(): string
{
parent::setUp();

$this->addCompilerPass(new PublicServicePass('/^Shivas\\\\VersioningBundle\\\\|^shivas_versioning.twig.version$/'));
return TestKernel::class;
}

protected function getBundleClass(): string
protected static function createKernel(array $options = []): KernelInterface
{
return ShivasVersioningBundle::class;
/** @var TestKernel $kernel */
$kernel = parent::createKernel($options);
$kernel->addTestBundle(ShivasVersioningBundle::class);
$kernel->addTestCompilerPass(new class implements CompilerPassInterface {
public function process(ContainerBuilder $container): void
{
// Service would be removed because it's unused.
$container->findDefinition('shivas_versioning.twig.version')->setPublic(true);
}
});
$kernel->handleOptions($options);

return $kernel;
}

public function testInitBundle()
Expand Down

0 comments on commit de3b1d7

Please sign in to comment.