Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'/s',
]),
],
'php_unit_attributes' => true,
])
->setRiskyAllowed(true)
->setFinder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -109,9 +110,7 @@ public function testResolveWithStripNulls()
$this->assertSame([], $resolver->resolve($request, $argument));
}

/**
* @dataProvider idsProvider
*/
#[DataProvider('idsProvider')]
public function testResolveWithId(string|int $id)
{
$manager = $this->createMock(ObjectManager::class);
Expand All @@ -137,9 +136,7 @@ public function testResolveWithId(string|int $id)
$this->assertSame([$object], $resolver->resolve($request, $argument));
}

/**
* @dataProvider idsProvider
*/
#[DataProvider('idsProvider')]
public function testResolveWithIdAndTypeAlias(string|int $id)
{
$manager = $this->getMockBuilder(ObjectManager::class)->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder;
Expand Down Expand Up @@ -148,9 +149,7 @@ public function testReset()
$this->assertEquals([], $c->getQueries());
}

/**
* @dataProvider paramProvider
*/
#[DataProvider('paramProvider')]
public function testCollectQueries($param, $types, $expected)
{
$queries = [
Expand Down Expand Up @@ -199,9 +198,7 @@ public function testCollectQueryWithNoParams()
$this->assertTrue($collectedQueries['default'][1]['runnable']);
}

/**
* @dataProvider paramProvider
*/
#[DataProvider('paramProvider')]
public function testSerialization($param, array $types, $expected)
{
$queries = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
Expand Down Expand Up @@ -145,9 +146,7 @@ public static function getAutomappingData()
];
}

/**
* @dataProvider getAutomappingData
*/
#[DataProvider('getAutomappingData')]
public function testFixManagersAutoMappings(array $originalEm1, array $originalEm2, array $expectedEm1, array $expectedEm2)
{
$emConfigs = [
Expand Down Expand Up @@ -187,9 +186,7 @@ public static function providerBasicDrivers(): array
];
}

/**
* @dataProvider providerBasicDrivers
*/
#[DataProvider('providerBasicDrivers')]
public function testLoadBasicCacheDriver(string $class, array $config, array $expectedCalls = [])
{
$container = $this->createContainer();
Expand Down Expand Up @@ -270,9 +267,7 @@ public static function providerBundles(): iterable
yield ['NewXmlBundle', 'xml', '/config/doctrine'];
}

/**
* @dataProvider providerBundles
*/
#[DataProvider('providerBundles')]
public function testBundleAutoMapping(string $bundle, string $expectedType, string $dirSuffix)
{
$bundleDir = __DIR__.'/../Fixtures/Bundles/'.$bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
Expand Down Expand Up @@ -111,9 +112,7 @@ public function testFilterNonIntegerValues()
$loader->getEntitiesByIds('id', [1, '', 2, 3, 'foo', '9223372036854775808']);
}

/**
* @dataProvider provideGuidEntityClasses
*/
#[DataProvider('provideGuidEntityClasses')]
public function testFilterEmptyUuids(string $entityClass)
{
$em = DoctrineTestHelper::createTestEntityManager();
Expand Down Expand Up @@ -145,9 +144,7 @@ public function testFilterEmptyUuids(string $entityClass)
$loader->getEntitiesByIds('id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499']);
}

/**
* @dataProvider provideUidEntityClasses
*/
#[DataProvider('provideUidEntityClasses')]
public function testFilterUid(string $entityClass)
{
if (Type::hasType('uuid')) {
Expand Down Expand Up @@ -188,9 +185,7 @@ public function testFilterUid(string $entityClass)
$loader->getEntitiesByIds('id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499']);
}

/**
* @dataProvider provideUidEntityClasses
*/
#[DataProvider('provideUidEntityClasses')]
public function testUidThrowProperException(string $entityClass)
{
if (Type::hasType('uuid')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\ORM\Mapping\ManyToOneAssociationMapping;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser;
use Symfony\Component\Form\Guess\Guess;
Expand All @@ -25,9 +26,7 @@

class DoctrineOrmTypeGuesserTest extends TestCase
{
/**
* @dataProvider requiredType
*/
#[DataProvider('requiredType')]
public function testTypeGuesser(string $type, $expected)
{
$classMetadata = $this->createMock(ClassMetadata::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\Attributes\Group;
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
Expand Down Expand Up @@ -81,9 +82,8 @@ protected function setUp(): void
/**
* This test case is realistic in collection forms where each
* row contains the same entity field.
*
* @group benchmark
*/
#[Group('benchmark')]
public function testCollapsedEntityField()
{
$this->setMaxRunningTime(1);
Expand All @@ -98,9 +98,7 @@ public function testCollapsedEntityField()
}
}

/**
* @group benchmark
*/
#[Group('benchmark')]
public function testCollapsedEntityFieldWithChoices()
{
$choices = $this->em->createQuery('SELECT c FROM '.self::ENTITY_CLASS.' c')->getResult();
Expand All @@ -117,9 +115,7 @@ public function testCollapsedEntityFieldWithChoices()
}
}

/**
* @group benchmark
*/
#[Group('benchmark')]
public function testCollapsedEntityFieldWithPreferredChoices()
{
$choices = $this->em->createQuery('SELECT c FROM '.self::ENTITY_CLASS.' c')->getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser;
Expand Down Expand Up @@ -119,9 +120,7 @@ public function testInvalidClassOption()
]);
}

/**
* @dataProvider choiceTranslationDomainProvider
*/
#[DataProvider('choiceTranslationDomainProvider')]
public function testChoiceTranslationDomainIsDisabledByDefault($expanded)
{
$entity1 = new SingleIntIdEntity(1, 'Foo');
Expand Down
9 changes: 4 additions & 5 deletions src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace Symfony\Bridge\Doctrine\Tests;

use Doctrine\Persistence\ObjectManager;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhp;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Tests\Fixtures\DummyManager;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -49,11 +51,8 @@ public function testResetService()
$this->assertFalse(isset($foo->bar));
}

/**
* @requires PHP 8.4
*
* @dataProvider provideResetServiceWithNativeLazyObjectsCases
*/
#[DataProvider('provideResetServiceWithNativeLazyObjectsCases')]
#[RequiresPhp('8.4')]
public function testResetServiceWithNativeLazyObjects(string $class)
{
$container = new $class();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\ORMSetup;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder;
use Symfony\Bridge\Doctrine\Middleware\Debug\Middleware;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Component\Stopwatch\Stopwatch;

/**
* @requires extension pdo_sqlite
*/
#[RequiresPhpExtension('pdo_sqlite')]
class MiddlewareTest extends TestCase
{
private DebugDataHolder $debugDataHolder;
Expand Down Expand Up @@ -93,9 +93,7 @@ public static function provideExecuteMethod(): array
];
}

/**
* @dataProvider provideExecuteMethod
*/
#[DataProvider('provideExecuteMethod')]
public function testWithoutBinding(callable $executeMethod)
{
$this->init();
Expand All @@ -110,9 +108,7 @@ public function testWithoutBinding(callable $executeMethod)
$this->assertGreaterThan(0, $debug[1]['executionMS']);
}

/**
* @dataProvider provideExecuteMethod
*/
#[DataProvider('provideExecuteMethod')]
public function testWithValueBound(callable $executeMethod)
{
$this->init();
Expand Down Expand Up @@ -140,9 +136,7 @@ public function testWithValueBound(callable $executeMethod)
$this->assertGreaterThan(0, $debug[1]['executionMS']);
}

/**
* @dataProvider provideExecuteMethod
*/
#[DataProvider('provideExecuteMethod')]
public function testWithParamBound(callable $executeMethod)
{
$this->init();
Expand Down Expand Up @@ -179,9 +173,7 @@ public static function provideEndTransactionMethod(): array
];
}

/**
* @dataProvider provideEndTransactionMethod
*/
#[DataProvider('provideEndTransactionMethod')]
public function testTransaction(callable $endTransactionMethod, string $expectedEndTransactionDebug)
{
$this->init();
Expand Down Expand Up @@ -237,9 +229,7 @@ public static function provideExecuteAndEndTransactionMethods(): array
];
}

/**
* @dataProvider provideExecuteAndEndTransactionMethods
*/
#[DataProvider('provideExecuteAndEndTransactionMethods')]
public function testGlobalDoctrineDuration(callable $sqlMethod, callable $endTransactionMethod)
{
$this->init();
Expand All @@ -263,9 +253,7 @@ public function testGlobalDoctrineDuration(callable $sqlMethod, callable $endTra
$this->assertCount(4, $this->stopwatch->getEvent('doctrine')->getPeriods());
}

/**
* @dataProvider provideExecuteAndEndTransactionMethods
*/
#[DataProvider('provideExecuteAndEndTransactionMethods')]
public function testWithoutStopwatch(callable $sqlMethod, callable $endTransactionMethod)
{
$this->init(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@

use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Middleware\IdleConnection\Driver;

class DriverTest extends TestCase
{
/**
* @group time-sensitive
*/
#[Group('time-sensitive')]
public function testConnect()
{
$driverMock = $this->createMock(DriverInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,7 @@ public function testExtractEnum()
$this->assertNull($this->createExtractor()->getType(DoctrineEnum::class, 'enumCustom'));
}

/**
* @dataProvider typeProvider
*/
#[DataProvider('typeProvider')]
public function testExtract(string $property, ?Type $type)
{
$this->assertEquals($type, $this->createExtractor()->getType(DoctrineDummy::class, $property, []));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\ORM\ORMSetup;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider;

/**
* @requires extension pdo_pgsql
*
* @group integration
*/
#[Group('integration')]
#[RequiresPhpExtension('pdo_pgsql')]
class DoctrineTokenProviderPostgresTest extends DoctrineTokenProviderTest
{
public static function setUpBeforeClass(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\ORM\ORMSetup;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider;
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
use Symfony\Component\Security\Core\Exception\TokenNotFoundException;

/**
* @requires extension pdo_sqlite
*/
#[RequiresPhpExtension('pdo_sqlite')]
class DoctrineTokenProviderTest extends TestCase
{
public function testCreateNewToken()
Expand Down
Loading
Loading