Skip to content

Commit

Permalink
Merge pull request #220 from symfony-cmf/4-to-5
Browse files Browse the repository at this point in the history
4 to 5
  • Loading branch information
dbu authored Apr 6, 2024
2 parents 9be0bcd + a00c429 commit d00ae5a
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 18 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
include:
- php-version: '8.1'
dependencies: 'lowest'
symfony-version: '^6.4'
- php-version: '8.1'
- php-version: '8.2'
- php-version: '8.3'
Expand All @@ -35,12 +36,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: 'composer:v2'

- name: Install Symfony Flex
run: |
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer global config --no-plugins allow-plugins.symfony/flex true
tools: composer:v2, flex

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2
Expand Down
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ Changelog
5.x
===

5.0.0
5.0.0
-----

* Support Symfony 7, drop support for Symfony < 6.4
* Drop support for Symfony < 6.4
* The default framework configuration no longer enables validation attributes.
* The phpcr-odm additional namespace is expected to use attributes rather than annotations.
* The PHPCR-ODM additional namespace is expected to use attributes rather than annotations.

4.x
===

4.5.0
-----

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

4.4.2
-----

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"symfony/phpunit-bridge": "^7.0.3"
},
"conflict": {
"doctrine/phpcr-bundle": "<3.0"
"doctrine/phpcr-odm": "<2.0",
"doctrine/phpcr-bundle": "<3.0",
"symfony/framework-bundle": "<6.4"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion resources/config/dist/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

$config = [
'secret' => 'test',
'test' => null,
'test' => true,
'form' => true,
'validation' => [
'enabled' => true,
Expand Down
9 changes: 5 additions & 4 deletions resources/config/dist/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@
],
],
],
'password_hashers' => [
'Symfony\Component\Security\Core\User\User' => 'plaintext',
],
];

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

$container->loadFromExtension('security', $config);
2 changes: 1 addition & 1 deletion src/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function getDbManager(string $type)
));
}

$dbManager = new $className($this->getContainer());
$dbManager = new $className(self::getContainer());

$this->dbManagers[$type] = $dbManager;

Expand Down
46 changes: 44 additions & 2 deletions tests/Functional/BaseTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@

use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
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\HttpKernel\KernelInterface;
Expand Down Expand Up @@ -53,6 +55,7 @@ protected function setUp(): void
->willReturnCallback(function ($name) use ($managerRegistry, $initializerManager) {
$dic = [
'test.client' => $this->client,
'test.service_container' => $this->container,
'doctrine_phpcr' => $managerRegistry,
'doctrine_phpcr.initializer_manager' => $initializerManager,
];
Expand All @@ -74,6 +77,7 @@ protected function setUp(): void
$this->testCase->setKernel($this->kernel);

$this->client = $this->createMock(KernelBrowser::class);

$this->client
->method('getContainer')
->willReturn($this->container);
Expand All @@ -83,7 +87,6 @@ public function testGetKernel(): void
{
$class = new \ReflectionClass(BaseTestCase::class);
$method = $class->getMethod('getKernel');
$method->setAccessible(true);

$this->assertInstanceOf(KernelInterface::class, $method->invoke(null));
}
Expand All @@ -92,8 +95,47 @@ public function testItCanProvideAFrameworkBundleClient(): void
{
$class = new \ReflectionClass(BaseTestCase::class);
$method = $class->getMethod('getFrameworkBundleClient');
$method->setAccessible(true);

$this->assertInstanceOf(KernelBrowser::class, $method->invoke($this->testCase));
}

public function provideTestDb()
{
return [
['PHPCR', 'PHPCR'],
['Phpcr', 'PHPCR'],
['ORM', 'ORM'],
['foobar', null],
];
}

/**
* @dataProvider provideTestDb
*/
public function testDb($dbName, $expected)
{
$class = new \ReflectionClass(BaseTestCase::class);
$method = $class->getMethod('getDbManager');

if (null === $expected) {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($dbName.'" does not exist');
}

$res = $method->invoke($this->testCase, $dbName);
if (null === $expected) {
// do not do assertions if the expected exception has not been thrown.
return;
}

$className = sprintf(
'Symfony\Cmf\Component\Testing\Functional\DbManager\%s',
$expected
);
if (PHPCR::class === $className && class_exists(RepositoryManager::class)) {
$className = RepositoryManager::class;
}

$this->assertInstanceOf($className, $res);
}
}

0 comments on commit d00ae5a

Please sign in to comment.