Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 to 5 #220

Merged
merged 7 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading