Skip to content

Commit

Permalink
fix setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Apr 5, 2024
1 parent 3b52fcb commit 72c7e2b
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 66 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,23 @@ jobs:
strategy:
fail-fast: false
matrix:
symfony-version:
- '*'
include:
- php-version: '7.1'
- php-version: '7.2'
dependencies: 'lowest'
symfony-version: '^3.4'
symfony-version: '^5.4'
symfony-deprecation-helper: 'weak'

- php-version: '7.2'
- php-version: '7.3'
symfony-version: '*'
- php-version: '7.4'
symfony-version: '^4.4'
- php-version: '7.4'
symfony-version: '5.0.*'
- php-version: '8.0'
symfony-version: '^5.4'
- php-version: '8.0'
symfony-version: '6.0.*'

- php-version: '8.1'
symfony-version: '^6.4'
- php-version: '8.2'
symfony-version: '*'
- php-version: '8.3'
symfony-version: '*'
steps:
- name: Checkout project
uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ Changelog
4.x
===

4.4.3
4.5.0
-----

* Support phpcr-bundle 3.
* Drop support for Symfony < 5.4

4.4.2
-----
Expand Down
24 changes: 14 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
}
],
"require": {
"php": "^7.1|^8.0",
"php": "^7.2|^8.0",
"doctrine/data-fixtures": "^1.2",
"symfony/browser-kit": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0"
"symfony/browser-kit": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
"doctrine/phpcr-bundle": "^1.3 || ^2.0 || ^3.0",
"symfony/console": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/doctrine-bridge": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/framework-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/http-kernel": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.4.6 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/monolog-bundle": "^3.5",
"symfony/security-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/twig-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.4"
"symfony/security-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^7.0.6",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"conflict": {
"symfony/framework-bundle": "<5.4.6"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 7 additions & 8 deletions resources/config/dist/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

$config = [
'secret' => 'test',
'test' => null,
'test' => true,
'form' => true,
'validation' => [
'enabled' => true,
'enable_annotations' => true,
],
'router' => [
'resource' => $routerPath,
Expand All @@ -29,14 +28,14 @@
'translator' => [
'fallback' => 'en',
],
'session' => [
'storage_factory_id' => 'session.storage.factory.mock_file',
],
];

if (interface_exists(\Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface::class)) {
// Symfony 5.3+
$config = array_merge($config, ['session' => ['storage_factory_id' => 'session.storage.factory.mock_file']]);
} else {
// Symfony <5.3
$config = array_merge($config, ['session' => ['storage_id' => 'session.storage.filesystem']]);
if (class_exists(\Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::class)) {
// Symfony < 7
$config['validation']['enable_annotations'] = true;
}

$container->loadFromExtension('framework', $config);
Expand Down
11 changes: 6 additions & 5 deletions resources/config/dist/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@
];

if (class_exists(\Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider::class)) {
// Symfony <=5.4
// Symfony 5.4
$config = array_merge($config, ['firewall' => ['main' => ['anonymous' => null]]]);
}

if (interface_exists(\Symfony\Component\PasswordHasher\PasswordHasherInterface::class)) {
unset($config['encoders']);
$config = array_merge($config, [
'enable_authenticator_manager' => true,
'password_hashers' => ['Symfony\Component\Security\Core\User\User' => 'plaintext'],
]);
$config['password_hashers'] = ['Symfony\Component\Security\Core\User\User' => 'plaintext'];
if (class_exists(\Symfony\Component\Security\Core\Security::class)) {
// Symfony 6 but not 7
$config['enable_authenticator_manager'] = true;
}
}

$container->loadFromExtension('security', $config);
17 changes: 1 addition & 16 deletions src/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Symfony\Cmf\Component\Testing\Functional\DbManager\ORM;
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
use Symfony\Cmf\Component\Testing\Functional\DbManager\PhpcrDecorator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;

Expand Down Expand Up @@ -80,18 +79,6 @@ protected static function bootKernel(array $options = []): KernelInterface
return parent::bootKernel(static::getKernelConfiguration());
}

/**
* BC with Symfony < 5.3 - when minimum version raises to ^5.3, we can remove this method.
*/
protected static function getContainer(): ContainerInterface
{
if (method_exists(KernelTestCase::class, 'getContainer')) {
return parent::getContainer();
}

return self::getKernel()->getContainer();
}

protected static function getKernel(): KernelInterface
{
if (null === static::$kernel) {
Expand All @@ -100,9 +87,7 @@ protected static function getKernel(): KernelInterface

if (static::$kernel instanceof KernelInterface) {
$kernelEnvironment = static::$kernel->getEnvironment();
$expectedEnvironment = isset(static::getKernelConfiguration()['environment'])
? static::getKernelConfiguration()['environment']
: 'phpcr';
$expectedEnvironment = static::getKernelConfiguration()['environment'] ?? 'phpcr';
if ($kernelEnvironment !== $expectedEnvironment) {
var_dump($kernelEnvironment, $expectedEnvironment);
static::bootKernel();
Expand Down
2 changes: 1 addition & 1 deletion src/HttpKernel/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected function registerConfiguredBundles()
}
}

protected function build(ContainerBuilder $container)
protected function build(ContainerBuilder $container): void
{
parent::build($container);
if (\in_array($this->getEnvironment(), ['test', 'phpcr']) && file_exists($this->getKernelDir().'/config/public_services.php')) {
Expand Down
25 changes: 11 additions & 14 deletions tests/Functional/BaseTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Cmf\Component\Testing\Tests\Functional;

use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
use Doctrine\Bundle\PHPCRBundle\ManagerRegistry;
use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -21,7 +22,9 @@
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
use Symfony\Cmf\Component\Testing\Tests\Fixtures\TestTestCase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\KernelInterface;

class BaseTestCaseTest extends TestCase
Expand All @@ -48,13 +51,18 @@ class BaseTestCaseTest extends TestCase

protected function setUp(): void
{
$this->container = $this->createMock(ContainerInterface::class);
$managerRegistry = interface_exists(ManagerRegistryInterface::class)
? $this->createMock(ManagerRegistryInterface::class)
: $this->createMock(ManagerRegistry::class)
;
$this->container = Kernel::MAJOR_VERSION >= 7 ? $this->createMock(Container::class) : $this->createMock(ContainerInterface::class);
$this->container
->method('get')
->willReturnCallback(function ($name) {
->willReturnCallback(function ($name) use ($managerRegistry) {
$dic = [
'test.client' => $this->client,
'doctrine_phpcr' => $this->createMock(ManagerRegistryInterface::class),
'test.service_container' => $this->container,
'doctrine_phpcr' => $managerRegistry,
'doctrine_phpcr.initializer_manager' => $this->createMock(InitializerManager::class),
];

Expand Down Expand Up @@ -85,15 +93,6 @@ protected function setUp(): void
->willReturn($this->container);
}

public function testGetContainer()
{
$class = new \ReflectionClass(BaseTestCase::class);
$method = $class->getMethod('getContainer');
$method->setAccessible(true);

$this->assertEquals($this->container, $method->invoke(null));
}

public function testGetKernel()
{
$class = new \ReflectionClass(BaseTestCase::class);
Expand Down Expand Up @@ -128,8 +127,6 @@ public function provideTestDb()

/**
* @dataProvider provideTestDb
*
* @depends testGetContainer
*/
public function testDb($dbName, $expected)
{
Expand Down

0 comments on commit 72c7e2b

Please sign in to comment.