Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2bf25db

Browse files
committed
Deprecated DoctrineBridge internal test helpers for outside use
1 parent d2e589c commit 2bf25db

11 files changed

+110
-10
lines changed

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.3.0
5+
-----
6+
7+
* deprecated `DoctrineTestHelper` and `TestRepositoryFactory`
8+
49
5.2.0
510
-----
611

src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* Provides utility functions needed in tests.
2626
*
2727
* @author Bernhard Schussek <[email protected]>
28+
*
29+
* @deprecated in 5.3, will be removed in 6.0.
2830
*/
2931
class DoctrineTestHelper
3032
{
@@ -39,8 +41,12 @@ public static function createTestEntityManager(Configuration $config = null)
3941
TestCase::markTestSkipped('Extension pdo_sqlite is required.');
4042
}
4143

44+
if (__CLASS__ === static::class) {
45+
trigger_deprecation('symfony/doctrine-bridge', '5.3', '"%s" is deprecated and will be removed in 6.0.', __CLASS__);
46+
}
47+
4248
if (null === $config) {
43-
$config = self::createTestConfiguration();
49+
$config = self::createTestConfiguration(false);
4450
}
4551

4652
$params = [
@@ -56,6 +62,10 @@ public static function createTestEntityManager(Configuration $config = null)
5662
*/
5763
public static function createTestConfiguration()
5864
{
65+
if (__CLASS__ === static::class) {
66+
trigger_deprecation('symfony/doctrine-bridge', '5.3', '"%s" is deprecated and will be removed in 6.0.', __CLASS__);
67+
}
68+
5969
$config = new Configuration();
6070
$config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']);
6171
$config->setAutoGenerateProxyClasses(true);
@@ -73,7 +83,11 @@ public static function createTestConfiguration()
7383
*/
7484
public static function createTestConfigurationWithXmlLoader()
7585
{
76-
$config = static::createTestConfiguration();
86+
if (__CLASS__ === static::class) {
87+
trigger_deprecation('symfony/doctrine-bridge', '5.3', '"%s" is deprecated and will be removed in 6.0.', __CLASS__);
88+
}
89+
90+
$config = static::createTestConfiguration(false);
7791

7892
$driverChain = new MappingDriverChain();
7993
$driverChain->addDriver(

src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
/**
2020
* @author Andreas Braun <[email protected]>
21+
*
22+
* @deprecated in 5.3, will be removed in 6.0.
2123
*/
22-
final class TestRepositoryFactory implements RepositoryFactory
24+
class TestRepositoryFactory implements RepositoryFactory
2325
{
2426
/**
2527
* @var ObjectRepository[]
@@ -33,6 +35,10 @@ final class TestRepositoryFactory implements RepositoryFactory
3335
*/
3436
public function getRepository(EntityManagerInterface $entityManager, $entityName)
3537
{
38+
if (__CLASS__ === static::class) {
39+
trigger_deprecation('symfony/doctrine-bridge', '5.3', '"%s" is deprecated and will be removed in 6.0.', __CLASS__);
40+
}
41+
3642
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
3743

3844
if (isset($this->repositoryList[$repositoryHash])) {
@@ -44,6 +50,10 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName
4450

4551
public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository)
4652
{
53+
if (__CLASS__ === static::class) {
54+
trigger_deprecation('symfony/doctrine-bridge', '5.3', '"%s" is deprecated and will be removed in 6.0.', __CLASS__);
55+
}
56+
4757
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
4858

4959
$this->repositoryList[$repositoryHash] = $repository;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests;
13+
14+
use Doctrine\ORM\Configuration;
15+
use Doctrine\ORM\EntityManager;
16+
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper as TestDoctrineTestHelper;
17+
18+
/**
19+
* Provides utility functions needed in tests.
20+
*
21+
* @author Bernhard Schussek <[email protected]>
22+
*/
23+
class DoctrineTestHelper extends TestDoctrineTestHelper
24+
{
25+
public static function createTestEntityManager(Configuration $config = null): EntityManager
26+
{
27+
return parent::createTestEntityManager($config);
28+
}
29+
30+
public static function createTestConfiguration(): Configuration
31+
{
32+
return parent::createTestConfiguration();
33+
}
34+
35+
public static function createTestConfigurationWithXmlLoader(): Configuration
36+
{
37+
return parent::createTestConfigurationWithXmlLoader();
38+
}
39+
}

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Doctrine\ORM\Version;
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
20-
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
20+
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
2121
use Symfony\Bridge\Doctrine\Types\UlidType;
2222
use Symfony\Bridge\Doctrine\Types\UuidType;
2323
use Symfony\Component\Form\Exception\TransformationFailedException;

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Doctrine\ORM\Tools\SchemaTool;
1515
use Doctrine\Persistence\ManagerRegistry;
1616
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
17-
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
17+
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
1818
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
1919
use Symfony\Component\Form\Extension\Core\CoreExtension;
2020
use Symfony\Component\Form\Test\FormPerformanceTestCase;

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
2121
use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser;
2222
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
23-
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
23+
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
2424
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity;
2525
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeStringIdEntity;
2626
use Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity;

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
2020
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
21-
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
21+
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
2222
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
2323
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
2424

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests;
13+
14+
use Doctrine\ORM\EntityManagerInterface;
15+
use Doctrine\Persistence\ObjectRepository;
16+
use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory as TestTestRepositoryFactory;
17+
18+
/**
19+
* @author Andreas Braun <[email protected]>
20+
*/
21+
final class TestRepositoryFactory extends TestTestRepositoryFactory
22+
{
23+
public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
24+
{
25+
return parent::getRepository($entityManager, $entityName);
26+
}
27+
28+
public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository): void
29+
{
30+
parent::setRepository($entityManager, $entityName, $repository);
31+
}
32+
}

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
use Doctrine\Persistence\Mapping\ClassMetadata;
1919
use Doctrine\Persistence\ObjectManager;
2020
use Doctrine\Persistence\ObjectRepository;
21-
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
22-
use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory;
21+
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
2322
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
2423
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2;
2524
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity;
@@ -31,6 +30,7 @@
3130
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
3231
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity;
3332
use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper;
33+
use Symfony\Bridge\Doctrine\Tests\TestRepositoryFactory;
3434
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
3535
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
3636
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\Tests\Validator;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
15+
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
1616
use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser;
1717
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEmbed;
1818
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEntity;

0 commit comments

Comments
 (0)