diff --git a/LICENSE b/LICENSE index 00837045..0138f8f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Middleware/Debug/Connection.php b/Middleware/Debug/Connection.php index 27eb35c0..f55a0d22 100644 --- a/Middleware/Debug/Connection.php +++ b/Middleware/Debug/Connection.php @@ -42,6 +42,7 @@ public function prepare(string $sql): DriverStatement $this->debugDataHolder, $this->connectionName, $sql, + $this->stopwatch, ); } diff --git a/Middleware/Debug/Statement.php b/Middleware/Debug/Statement.php index 0157c5db..67cf2f5e 100644 --- a/Middleware/Debug/Statement.php +++ b/Middleware/Debug/Statement.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\Driver\Result as ResultInterface; use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\ParameterType; +use Symfony\Component\Stopwatch\Stopwatch; /** * @author Laurent VOULLEMIER @@ -30,6 +31,7 @@ public function __construct( private DebugDataHolder $debugDataHolder, private string $connectionName, string $sql, + private ?Stopwatch $stopwatch = null, ) { parent::__construct($statement); @@ -59,12 +61,14 @@ public function execute($params = null): ResultInterface // clone to prevent variables by reference to change $this->debugDataHolder->addQuery($this->connectionName, $query = clone $this->query); + $this->stopwatch?->start('doctrine', 'doctrine'); $query->start(); try { $result = parent::execute($params); } finally { $query->stop(); + $this->stopwatch?->stop('doctrine'); } return $result; diff --git a/Tests/ArgumentResolver/EntityValueResolverTest.php b/Tests/ArgumentResolver/EntityValueResolverTest.php index 3dc814ac..883af012 100644 --- a/Tests/ArgumentResolver/EntityValueResolverTest.php +++ b/Tests/ArgumentResolver/EntityValueResolverTest.php @@ -187,7 +187,7 @@ public function testUsedProperIdentifier() $this->assertSame([null], $resolver->resolve($request, $argument)); } - public function idsProvider(): iterable + public static function idsProvider(): iterable { yield [1]; yield [0]; diff --git a/Tests/DataCollector/DoctrineDataCollectorTest.php b/Tests/DataCollector/DoctrineDataCollectorTest.php index 25cc33fb..8146adb9 100644 --- a/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -134,7 +134,7 @@ public function testSerialization($param, array $types, $expected) $this->assertTrue($collectedQueries['default'][0]['runnable']); } - public function paramProvider(): array + public static function paramProvider(): array { return [ ['some value', [], 'some value'], diff --git a/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php b/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php index f0962eff..64bee120 100644 --- a/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php +++ b/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php @@ -107,7 +107,7 @@ public function testSerialization($param, array $types, $expected, $explainable, $this->assertSame($runnable, $collectedQueries['default'][0]['runnable']); } - public function paramProvider(): array + public static function paramProvider(): array { return [ ['some value', [], 'some value', true], diff --git a/Tests/DependencyInjection/DoctrineExtensionTest.php b/Tests/DependencyInjection/DoctrineExtensionTest.php index 2ca6eda3..2a772165 100644 --- a/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->extension = $this ->getMockBuilder(AbstractDoctrineExtension::class) - ->setMethods([ + ->onlyMethods([ 'getMappingResourceConfigDirectory', 'getObjectManagerElementName', 'getMappingObjectDefaultName', @@ -83,7 +83,7 @@ public function testFixManagersAutoMappingsWithTwoAutomappings() $method->invoke($this->extension, $emConfigs, $bundles); } - public function getAutomappingData() + public static function getAutomappingData() { return [ [ @@ -194,7 +194,7 @@ public function testMappingTypeDetection() $this->assertSame($mappingType, 'attribute'); } - public function providerBasicDrivers() + public static function providerBasicDrivers() { return [ ['doctrine.orm.cache.apc.class', ['type' => 'apc']], @@ -273,7 +273,7 @@ public function testUnrecognizedCacheDriverException() $this->invokeLoadCacheDriver($objectManager, $container, $cacheName); } - public function providerBundles() + public static function providerBundles() { yield ['AnnotationsBundle', 'annotation', '/Entity']; yield ['AnnotationsOneLineBundle', 'annotation', '/Entity']; diff --git a/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php b/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php index efb3b048..3a626bb1 100644 --- a/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -12,8 +12,10 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Result; use Doctrine\DBAL\Types\GuidType; use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\AbstractQuery; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper; @@ -45,8 +47,8 @@ protected function checkIdentifierType($classname, $expectedType) { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder(\QueryMock::class) - ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) + $query = $this->getMockBuilder(QueryMock::class) + ->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query @@ -60,7 +62,7 @@ protected function checkIdentifierType($classname, $expectedType) $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) - ->setMethods(['getQuery']) + ->onlyMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) @@ -78,8 +80,8 @@ public function testFilterNonIntegerValues() { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder(\QueryMock::class) - ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) + $query = $this->getMockBuilder(QueryMock::class) + ->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query @@ -93,7 +95,7 @@ public function testFilterNonIntegerValues() $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) - ->setMethods(['getQuery']) + ->onlyMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) @@ -114,8 +116,8 @@ public function testFilterEmptyUuids($entityClass) { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder(\QueryMock::class) - ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) + $query = $this->getMockBuilder(QueryMock::class) + ->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query @@ -129,7 +131,7 @@ public function testFilterEmptyUuids($entityClass) $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) - ->setMethods(['getQuery']) + ->onlyMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) @@ -159,8 +161,8 @@ public function testFilterUid($entityClass) $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder(\QueryMock::class) - ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) + $query = $this->getMockBuilder(QueryMock::class) + ->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query @@ -174,7 +176,7 @@ public function testFilterUid($entityClass) $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) - ->setMethods(['getQuery']) + ->onlyMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) @@ -206,7 +208,7 @@ public function testUidThrowProperException($entityClass) $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) - ->setMethods(['getQuery']) + ->onlyMethods(['getQuery']) ->getMock(); $qb->expects($this->never()) @@ -227,8 +229,8 @@ public function testEmbeddedIdentifierName() { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder(\QueryMock::class) - ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) + $query = $this->getMockBuilder(QueryMock::class) + ->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query @@ -242,7 +244,7 @@ public function testEmbeddedIdentifierName() $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) - ->setMethods(['getQuery']) + ->onlyMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) ->method('getQuery') @@ -255,7 +257,7 @@ public function testEmbeddedIdentifierName() $loader->getEntitiesByIds('id.value', [1, '', 2, 3, 'foo']); } - public function provideGuidEntityClasses() + public static function provideGuidEntityClasses() { return [ ['Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'], @@ -263,7 +265,7 @@ public function provideGuidEntityClasses() ]; } - public function provideUidEntityClasses() + public static function provideUidEntityClasses() { return [ ['Symfony\Bridge\Doctrine\Tests\Fixtures\UuidIdEntity'], @@ -271,3 +273,24 @@ public function provideUidEntityClasses() ]; } } + +class QueryMock extends AbstractQuery +{ + public function __construct() + { + } + + /** + * @return array|string + */ + public function getSQL() + { + } + + /** + * @return Result|int + */ + protected function _doExecute() + { + } +} diff --git a/Tests/Form/DoctrineOrmTypeGuesserTest.php b/Tests/Form/DoctrineOrmTypeGuesserTest.php index 652f9d67..f211f291 100644 --- a/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -35,7 +35,7 @@ public function testTypeGuesser(string $type, $expected) $this->assertEquals($expected, $this->getGuesser($classMetadata)->guessType('TestEntity', 'field')); } - public function requiredType() + public static function requiredType() { yield [Types::DATE_IMMUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE)]; yield [Types::DATE_MUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', [], Guess::HIGH_CONFIDENCE)]; @@ -49,66 +49,63 @@ public function requiredType() yield [Types::DATETIMETZ_MUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', [], Guess::HIGH_CONFIDENCE)]; } - /** - * @dataProvider requiredProvider - */ - public function testRequiredGuesser($classMetadata, $expected) - { - $this->assertEquals($expected, $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); - } - - public function requiredProvider() + public function testRequiredGuesserSimpleFieldNotNullable() { - $return = []; - - // Simple field, not nullable $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false); - $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(true, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // Simple field, nullable + public function testRequiredGuesserSimpleFieldNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true); - $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(false, Guess::MEDIUM_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-one, nullable (by default) + public function testRequiredGuesserOneToOneNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [[]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); - $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(false, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-one, nullable (explicit) + public function testRequiredGuesserOneToOneExplicitNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => true]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); - $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(false, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-one, not nullable + public function testRequiredGuesserOneToOneNotNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => false]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); - $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(true, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-many, no clue + public function testRequiredGuesserOneToMany() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false); - $return[] = [$classMetadata, null]; - - return $return; + $this->assertNull($this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); } private function getGuesser(ClassMetadata $classMetadata) diff --git a/Tests/Form/Type/EntityTypeTest.php b/Tests/Form/Type/EntityTypeTest.php index 18f918dd..3d752afd 100644 --- a/Tests/Form/Type/EntityTypeTest.php +++ b/Tests/Form/Type/EntityTypeTest.php @@ -35,12 +35,12 @@ use Symfony\Component\Form\Exception\RuntimeException; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Forms; -use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest; +use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTestCase; use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; -class EntityTypeTest extends BaseTypeTest +class EntityTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Bridge\Doctrine\Form\Type\EntityType'; @@ -158,7 +158,7 @@ public function testChoiceTranslationDomainIsDisabledByDefault($expanded) } } - public function choiceTranslationDomainProvider() + public static function choiceTranslationDomainProvider() { return [ [false], diff --git a/Tests/Logger/DbalLoggerTest.php b/Tests/Logger/DbalLoggerTest.php index 710e87a1..2e9ed80e 100644 --- a/Tests/Logger/DbalLoggerTest.php +++ b/Tests/Logger/DbalLoggerTest.php @@ -30,7 +30,7 @@ public function testLog($sql, $params, $logParams) $dbalLogger = $this ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) - ->setMethods(['log']) + ->onlyMethods(['log']) ->getMock() ; @@ -43,7 +43,7 @@ public function testLog($sql, $params, $logParams) $dbalLogger->startQuery($sql, $params); } - public function getLogFixtures() + public static function getLogFixtures() { return [ ['SQL', null, []], @@ -62,7 +62,7 @@ public function testLogNonUtf8() $dbalLogger = $this ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) - ->setMethods(['log']) + ->onlyMethods(['log']) ->getMock() ; @@ -85,7 +85,7 @@ public function testLogNonUtf8Array() $dbalLogger = $this ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) - ->setMethods(['log']) + ->onlyMethods(['log']) ->getMock() ; @@ -116,7 +116,7 @@ public function testLogLongString() $dbalLogger = $this ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) - ->setMethods(['log']) + ->onlyMethods(['log']) ->getMock() ; @@ -144,7 +144,7 @@ public function testLogUTF8LongString() $dbalLogger = $this ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) - ->setMethods(['log']) + ->onlyMethods(['log']) ->getMock() ; diff --git a/Tests/ManagerRegistryTest.php b/Tests/ManagerRegistryTest.php index dd7dabcc..e524ebce 100644 --- a/Tests/ManagerRegistryTest.php +++ b/Tests/ManagerRegistryTest.php @@ -44,7 +44,8 @@ public function testResetService() $registry->resetManager(); $this->assertSame($foo, $container->get('foo')); - $this->assertObjectNotHasAttribute('bar', $foo); + $this->assertInstanceOf(\stdClass::class, $foo); + $this->assertFalse(property_exists($foo, 'bar')); } /** diff --git a/Tests/Middleware/Debug/MiddlewareTest.php b/Tests/Middleware/Debug/MiddlewareTest.php index de9d5370..e605afec 100644 --- a/Tests/Middleware/Debug/MiddlewareTest.php +++ b/Tests/Middleware/Debug/MiddlewareTest.php @@ -16,6 +16,7 @@ use Doctrine\DBAL\Driver\Middleware as MiddlewareInterface; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\ParameterType; +use Doctrine\DBAL\Result; use Doctrine\DBAL\Statement; use Doctrine\DBAL\Types\Types; use PHPUnit\Framework\TestCase; @@ -78,7 +79,7 @@ private function getResourceFromString(string $str) return $res; } - public function provideExecuteMethod(): array + public static function provideExecuteMethod(): array { return [ 'executeStatement' => [ @@ -156,10 +157,6 @@ public function testWithParamBound(callable $executeMethod) $executeMethod($stmt); // Debug data should not be affected by these changes - $product = 'product2'; - $price = 13.5; - $stock = 4; - $debug = $this->debugDataHolder->getData()['default'] ?? []; $this->assertCount(2, $debug); $this->assertSame('INSERT INTO products(name, price, stock) VALUES (?, ?, ?)', $debug[1]['sql']); @@ -168,7 +165,7 @@ public function testWithParamBound(callable $executeMethod) $this->assertGreaterThan(0, $debug[1]['executionMS']); } - public function provideEndTransactionMethod(): array + public static function provideEndTransactionMethod(): array { return [ 'commit' => [static fn (Connection $conn) => $conn->commit(), '"COMMIT"'], @@ -208,7 +205,7 @@ public function testTransaction(callable $endTransactionMethod, string $expected $this->assertGreaterThan(0, $debug[6]['executionMS']); } - public function provideExecuteAndEndTransactionMethods(): array + public static function provideExecuteAndEndTransactionMethods(): array { return [ 'commit and exec' => [ @@ -219,6 +216,14 @@ public function provideExecuteAndEndTransactionMethods(): array static fn (Connection $conn, string $sql) => $conn->executeQuery($sql), static fn (Connection $conn) => $conn->rollBack(), ], + 'prepared statement' => [ + static function (Connection $conn, string $sql): Result { + return $conn->prepare($sql)->executeQuery(); + }, + static function (Connection $conn): bool { + return $conn->commit(); + }, + ], ]; } diff --git a/Tests/PropertyInfo/DoctrineExtractorTest.php b/Tests/PropertyInfo/DoctrineExtractorTest.php index 3771e772..631d8035 100644 --- a/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -135,7 +135,7 @@ public function testExtractEnum() $this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', [])); } - public function typesProvider() + public static function typesProvider() { $provider = [ ['id', [new Type(Type::BUILTIN_TYPE_INT)]], diff --git a/Tests/Security/User/EntityUserProviderTest.php b/Tests/Security/User/EntityUserProviderTest.php index ca4f091b..c17c3e2c 100644 --- a/Tests/Security/User/EntityUserProviderTest.php +++ b/Tests/Security/User/EntityUserProviderTest.php @@ -211,7 +211,7 @@ private function getManager($em, $name = null) private function getObjectManager($repository) { $em = $this->getMockBuilder(ObjectManager::class) - ->setMethods(['getClassMetadata', 'getRepository']) + ->onlyMethods(['getClassMetadata', 'getRepository']) ->getMockForAbstractClass(); $em->expects($this->any()) ->method('getRepository') diff --git a/Tests/Types/UlidTypeTest.php b/Tests/Types/UlidTypeTest.php index 8fd4b8b0..06114aee 100644 --- a/Tests/Types/UlidTypeTest.php +++ b/Tests/Types/UlidTypeTest.php @@ -140,7 +140,7 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string $this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform)); } - public function provideSqlDeclarations(): array + public static function provideSqlDeclarations(): array { return [ [new PostgreSQLPlatform(), 'UUID'], diff --git a/Tests/Types/UuidTypeTest.php b/Tests/Types/UuidTypeTest.php index 9b904b89..d49afc5f 100644 --- a/Tests/Types/UuidTypeTest.php +++ b/Tests/Types/UuidTypeTest.php @@ -152,7 +152,7 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string $this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform)); } - public function provideSqlDeclarations(): array + public static function provideSqlDeclarations(): array { return [ [new PostgreSQLPlatform(), 'UUID'], diff --git a/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index f752a0cf..3176ac22 100644 --- a/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -96,7 +96,8 @@ protected function createRegistryMock($em = null) protected function createRepositoryMock() { $repository = $this->getMockBuilder(ObjectRepository::class) - ->setMethods(['findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName']) + ->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName']) + ->addMethods(['findByCustom']) ->getMock() ; @@ -186,7 +187,7 @@ public function testValidateUniqueness(UniqueEntity $constraint) ->assertRaised(); } - public function provideUniquenessConstraints(): iterable + public static function provideUniquenessConstraints(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -219,7 +220,7 @@ public function testValidateCustomErrorPath(UniqueEntity $constraint) ->assertRaised(); } - public function provideConstraintsWithCustomErrorPath(): iterable + public static function provideConstraintsWithCustomErrorPath(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -278,7 +279,7 @@ public function testValidateUniquenessWithIgnoreNullDisabled(UniqueEntity $const ->assertRaised(); } - public function provideConstraintsWithIgnoreNullDisabled(): iterable + public static function provideConstraintsWithIgnoreNullDisabled(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -325,7 +326,7 @@ public function testNoValidationIfFirstFieldIsNullAndNullValuesAreIgnored(Unique $this->assertNoViolation(); } - public function provideConstraintsWithIgnoreNullEnabled(): iterable + public static function provideConstraintsWithIgnoreNullEnabled(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -424,7 +425,7 @@ function () use ($entity) { $this->assertNoViolation(); } - public function provideConstraintsWithCustomRepositoryMethod(): iterable + public static function provideConstraintsWithCustomRepositoryMethod(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -463,7 +464,7 @@ public function testValidateResultTypes($entity1, $result) $this->assertNoViolation(); } - public function resultTypesProvider() + public static function resultTypesProvider() { $entity = new SingleIntIdEntity(1, 'foo'); @@ -876,7 +877,7 @@ public function testValueCanBeNull() $this->assertNoViolation(); } - public function resultWithEmptyIterator(): array + public static function resultWithEmptyIterator(): array { $entity = new SingleIntIdEntity(1, 'foo'); diff --git a/Tests/Validator/DoctrineLoaderTest.php b/Tests/Validator/DoctrineLoaderTest.php index 23c7e758..eb83aecb 100644 --- a/Tests/Validator/DoctrineLoaderTest.php +++ b/Tests/Validator/DoctrineLoaderTest.php @@ -198,7 +198,7 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp $this->assertSame($expected, $doctrineLoader->loadClassMetadata($classMetadata)); } - public function regexpProvider() + public static function regexpProvider() { return [ [false, null], diff --git a/composer.json b/composer.json index abb0cd42..74307583 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "symfony/cache": "^5.4|^6.0", "symfony/config": "^5.4|^6.0", "symfony/dependency-injection": "^5.4|^6.0", - "symfony/form": "^5.4.9|^6.0.9", + "symfony/form": "^5.4.21|^6.2.7", "symfony/http-kernel": "^6.2", "symfony/messenger": "^5.4|^6.0", "symfony/doctrine-messenger": "^5.4|^6.0", @@ -56,7 +56,7 @@ "phpunit/phpunit": "<5.4.3", "symfony/cache": "<5.4", "symfony/dependency-injection": "<5.4", - "symfony/form": "<5.4", + "symfony/form": "<5.4.21|>=6,<6.2.7", "symfony/http-kernel": "<6.2", "symfony/messenger": "<5.4", "symfony/property-info": "<5.4",