Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.x' into 4-to-5
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Apr 5, 2024
2 parents 9be0bcd + 05a1992 commit bee2cd0
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 16 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
include:
- php-version: '8.1'
dependencies: 'lowest'
symfony-version: '^6.4'
symfony-deprecation-helper: 'weak'
- php-version: '8.1'
- php-version: '8.2'
- php-version: '8.3'
Expand All @@ -35,12 +37,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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"symfony/phpunit-bridge": "^7.0.3"
},
"conflict": {
"doctrine/phpcr-bundle": "<3.0"
"doctrine/phpcr-bundle": "<3.0",
"symfony/framework-bundle": "<5.4.6"
},
"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
10 changes: 6 additions & 4 deletions resources/config/dist/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
],
],
],
'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);
9 changes: 8 additions & 1 deletion src/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@ protected function getDbManager(string $type)
));
}

$dbManager = new $className($this->getContainer());
$refl = new \ReflectionClass($className);
if (1 === $refl->getConstructor()->getNumberOfParameters()) {
// phpcr-bundle < 3
$dbManager = new $className(self::getContainer());
} else {
// phpcr-bundle >= 3
$dbManager = new $className(self::getContainer()->get('doctrine_phpcr'), self::getContainer()->get('doctrine_phpcr.initializer_manager'));
}

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

Expand Down
43 changes: 43 additions & 0 deletions tests/Functional/BaseTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

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;
Expand Down Expand Up @@ -74,6 +75,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 @@ -96,4 +98,45 @@ public function testItCanProvideAFrameworkBundleClient(): void

$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');
$method->setAccessible(true);

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 bee2cd0

Please sign in to comment.