Skip to content

Commit

Permalink
allow doctrine/persistence ^4.0 (#1826)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher authored Jan 31, 2025
1 parent 1f68177 commit 6369dcb
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 36 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"doctrine/dbal": "^3.4 || ^4.0",
"doctrine/doctrine-bundle": "^2.10",
"doctrine/orm": "^2.17 || ^3.0",
"doctrine/persistence": "^3.0.2",
"doctrine/persistence": "^3.0.2 || ^4.0",
"sonata-project/admin-bundle": "^4.34",
"sonata-project/exporter": "^2.0 || ^3.0",
"sonata-project/form-extensions": "^1.19 || ^2.0",
Expand All @@ -47,8 +47,9 @@
"twig/twig": "^3.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
"dama/doctrine-test-bundle": "^8.0",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"doctrine/doctrine-fixtures-bundle": "^3.4 || ^4.0",
"friendsofphp/php-cs-fixer": "^3.4",
"matthiasnoback/symfony-dependency-injection-test": "^4.2 || ^5.0",
"phpstan/extension-installer": "^1.0",
Expand Down
19 changes: 12 additions & 7 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\UX\StimulusBundle\StimulusBundle;

final class AppKernel extends Kernel
{
use MicroKernelTrait;

/** @psalm-suppress InvalidReturnType */

Check failure on line 41 in tests/App/AppKernel.php

View workflow job for this annotation

GitHub Actions / Psalm

UnusedPsalmSuppress

tests/App/AppKernel.php:41:25: UnusedPsalmSuppress: This suppression is never used (see https://psalm.dev/207)
public function registerBundles(): iterable
{
return [
$bundles = [
new DoctrineBundle(),
new DAMADoctrineTestBundle(),
new FrameworkBundle(),
Expand All @@ -56,6 +57,15 @@ public function registerBundles(): iterable
new TwigBundle(),
new DoctrineFixturesBundle(),
];

if (class_exists(StimulusBundle::class)) {
$bundles[] = new StimulusBundle();
}

/**
* @psalm-suppress InvalidReturnStatement

Check failure on line 66 in tests/App/AppKernel.php

View workflow job for this annotation

GitHub Actions / Psalm

UnusedPsalmSuppress

tests/App/AppKernel.php:66:28: UnusedPsalmSuppress: This suppression is never used (see https://psalm.dev/207)
*/
return $bundles; /* @phpstan-ignore return.type */

Check failure on line 68 in tests/App/AppKernel.php

View workflow job for this annotation

GitHub Actions / PHPStan

No error with identifier return.type is reported on line 68.
}

public function getCacheDir(): string
Expand Down Expand Up @@ -83,11 +93,6 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
$container->setParameter('app.base_dir', $this->getBaseDir());

$loader->load(__DIR__.'/config/config.yml');

if (!class_exists(IsGranted::class)) {
$loader->load(__DIR__.'/config/config_symfony_v5.yml');
}

$loader->load(__DIR__.'/config/services.php');
}

Expand Down
2 changes: 0 additions & 2 deletions tests/App/config/config_symfony_v5.yml

This file was deleted.

12 changes: 6 additions & 6 deletions tests/Builder/DatagridBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ final class DatagridBuilderTest extends TestCase

protected function setUp(): void
{
$this->formFactory = $this->createStub(FormFactoryInterface::class);
$this->filterFactory = $this->createStub(FilterFactoryInterface::class);
$this->typeGuesser = $this->createStub(TypeGuesserInterface::class);
$this->formFactory = static::createStub(FormFactoryInterface::class);
$this->filterFactory = static::createStub(FilterFactoryInterface::class);
$this->typeGuesser = static::createStub(TypeGuesserInterface::class);

$this->datagridBuilder = new DatagridBuilder(
$this->formFactory,
Expand All @@ -85,9 +85,9 @@ protected function setUp(): void
*/
public function testGetBaseDatagrid(string $pagerType, string $pager): void
{
$proxyQuery = $this->createStub(ProxyQueryInterface::class);
$proxyQuery = static::createStub(ProxyQueryInterface::class);
$fieldDescriptionCollection = new FieldDescriptionCollection();
$formBuilder = $this->createStub(FormBuilderInterface::class);
$formBuilder = static::createStub(FormBuilderInterface::class);

$this->admin->method('getPagerType')->willReturn($pagerType);
$this->admin->method('createQuery')->willReturn($proxyQuery);
Expand Down Expand Up @@ -147,7 +147,7 @@ public function testFixFieldDescriptionWithoutFieldName(): void
public function testAddFilterNoType(): void
{
$datagrid = $this->createMock(DatagridInterface::class);
$guessType = $this->createStub(TypeGuess::class);
$guessType = static::createStub(TypeGuess::class);

$fieldDescription = new FieldDescription('test');
$fieldDescription->setAdmin($this->admin);
Expand Down
2 changes: 1 addition & 1 deletion tests/Builder/ListBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class ListBuilderTest extends TestCase

protected function setUp(): void
{
$this->typeGuesser = $this->createStub(TypeGuesserInterface::class);
$this->typeGuesser = static::createStub(TypeGuesserInterface::class);
$this->admin = $this->createMock(AdminInterface::class);

$this->admin->method('getClass')->willReturn('Foo');
Expand Down
4 changes: 2 additions & 2 deletions tests/Builder/ShowBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class ShowBuilderTest extends TestCase

protected function setUp(): void
{
$this->guesser = $this->createStub(TypeGuesserInterface::class);
$this->guesser = static::createStub(TypeGuesserInterface::class);

$this->showBuilder = new ShowBuilder(
$this->guesser,
Expand All @@ -69,7 +69,7 @@ public function testGetBaseList(): void

public function testAddFieldNoType(): void
{
$typeGuess = $this->createStub(TypeGuess::class);
$typeGuess = static::createStub(TypeGuess::class);

$fieldDescription = new FieldDescription('FakeName', [], ['type' => ClassMetadata::MANY_TO_ONE]);
$fieldDescription->setAdmin($this->admin);
Expand Down
8 changes: 4 additions & 4 deletions tests/Exporter/DataSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ protected function setUp(): void

public function testCreateIterator(): void
{
$configuration = $this->createStub(Configuration::class);
$configuration = static::createStub(Configuration::class);
$configuration->method('getDefaultQueryHints')->willReturn([]);

$em = $this->createStub(EntityManager::class);
$em = static::createStub(EntityManager::class);
$em->method('getConfiguration')->willReturn($configuration);

$queryBuilder = $this->getMockBuilder(QueryBuilder::class)
Expand All @@ -61,10 +61,10 @@ public function testCreateIterator(): void

public function testCreateIteratorWithNormalSortBy(): void
{
$configuration = $this->createStub(Configuration::class);
$configuration = static::createStub(Configuration::class);
$configuration->method('getDefaultQueryHints')->willReturn([]);

$em = $this->createStub(EntityManager::class);
$em = static::createStub(EntityManager::class);
$em->method('getConfiguration')->willReturn($configuration);

$queryBuilder = $this->getMockBuilder(QueryBuilder::class)
Expand Down
2 changes: 1 addition & 1 deletion tests/FieldDescription/FieldDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function testGetValueWhenCannotRetrieve(): void
$mockedObject = $this->getMockBuilder(\stdClass::class)->addMethods(['myMethod'])->getMock();
$mockedObject->expects(static::never())->method('myMethod')->willReturn('myMethodValue');

$admin = $this->createStub(AdminInterface::class);
$admin = static::createStub(AdminInterface::class);
$field = new FieldDescription('name');
$field->setAdmin($admin);

Expand Down
2 changes: 1 addition & 1 deletion tests/FieldDescription/FilterTypeGuesserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testGuess(
int $expectedConfidence,
array $fieldMapping = [],
): void {
$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);
$fieldDescription->method('getFieldName')->willReturn('foo');
$fieldDescription->method('getMappingType')->willReturn($mappingType);
$fieldDescription->method('getParentAssociationMappings')->willReturn([]);
Expand Down
2 changes: 1 addition & 1 deletion tests/FieldDescription/TypeGuesserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testGuess(
array $expectedOptions,
int $expectedConfidence,
): void {
$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);
$fieldDescription->method('getFieldName')->willReturn('foo');
$fieldDescription->method('getMappingType')->willReturn($mappingType);

Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class FilterTest extends FilterTestCase
*/
public function testOrExpression(string $expected, array $filterOptionsCollection = []): void
{
$entityManager = $this->createStub(EntityManagerInterface::class);
$entityManager = static::createStub(EntityManagerInterface::class);
$entityManager->method('getExpressionBuilder')->willReturn(new Expr());
$queryBuilder = new TestQueryBuilder($entityManager);

Expand Down
6 changes: 3 additions & 3 deletions tests/Filter/FilterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final protected static function assertSameQueryParameters(array $expected, Proxy

final protected function createQueryBuilderStub(): TestQueryBuilder
{
$queryBuilder = $this->createStub(TestQueryBuilder::class);
$queryBuilder = static::createStub(TestQueryBuilder::class);

$queryBuilder->method('getEntityManager')->willReturnCallback(
fn (): EntityManagerInterface => $this->createEntityManagerStub()
Expand Down Expand Up @@ -115,8 +115,8 @@ static function (string $parameter, string $alias) use ($queryBuilder): TestQuer

private function createEntityManagerStub(): EntityManagerInterface
{
$classMetadata = $this->createStub(ClassMetadata::class);
$entityManager = $this->createStub(EntityManagerInterface::class);
$classMetadata = static::createStub(ClassMetadata::class);
$entityManager = static::createStub(EntityManagerInterface::class);

$classMetadata->method('getIdentifierValues')->willReturnCallback(
static fn (mixed $value): array => ['id' => $value]
Expand Down
4 changes: 2 additions & 2 deletions tests/Model/ModelManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public function testFailingBatchDelete(string $expectedExceptionMessage, ?array
$connection = $this->createMock(Connection::class);
$connection
->method('getDatabasePlatform')
->willReturn($this->createStub(AbstractPlatform::class));
->willReturn(static::createStub(AbstractPlatform::class));
$connection
->method('getParams')
->willReturn([]);
Expand Down Expand Up @@ -776,7 +776,7 @@ public function provideAddIdentifiersToQueryCases(): iterable
*/
public function testAddIdentifiersToQueryWithEmptyIdentifiers(): void
{
$datagrid = $this->createStub(ProxyQueryInterface::class);
$datagrid = static::createStub(ProxyQueryInterface::class);

$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Array passed as argument 3 to "Sonata\DoctrineORMAdminBundle\Model\ModelManager::addIdentifiersToQuery()" must not be empty.');
Expand Down
6 changes: 3 additions & 3 deletions tests/Util/SmartPaginatorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class SmartPaginatorFactoryTest extends TestCase
public function testFetchJoinedCollection(QueryBuilder $queryBuilder, bool $expected): void
{
/** @var ProxyQueryInterface<object>&MockObject $proxyQuery */
$proxyQuery = $this->createStub(ProxyQueryInterface::class);
$proxyQuery = static::createStub(ProxyQueryInterface::class);
$proxyQuery
->method('getQueryBuilder')
->willReturn($queryBuilder);
Expand Down Expand Up @@ -82,7 +82,7 @@ public function provideFetchJoinedCollectionCases(): iterable
public function testUseOutputWalker(QueryBuilder $queryBuilder, ?bool $expected, ?string $sortBy = null): void
{
/** @var ProxyQueryInterface<object>&MockObject $proxyQuery */
$proxyQuery = $this->createStub(ProxyQueryInterface::class);
$proxyQuery = static::createStub(ProxyQueryInterface::class);
$proxyQuery
->method('getQueryBuilder')
->willReturn($queryBuilder);
Expand Down Expand Up @@ -195,7 +195,7 @@ public function provideUseOutputWalkerCases(): iterable
public function testCountWalkerDistinct(QueryBuilder $queryBuilder, bool $hasHint, bool $expected): void
{
/** @var ProxyQueryInterface<object>&MockObject $proxyQuery */
$proxyQuery = $this->createStub(ProxyQueryInterface::class);
$proxyQuery = static::createStub(ProxyQueryInterface::class);
$proxyQuery
->method('getQueryBuilder')
->willReturn($queryBuilder);
Expand Down

0 comments on commit 6369dcb

Please sign in to comment.