Skip to content

Commit f0e48a0

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

File tree

11 files changed

+114
-15
lines changed

11 files changed

+114
-15
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: 19 additions & 5 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 <bschussek@gmail.com>
28+
*
29+
* @deprecated in 5.3, will be removed in 6.0.
2830
*/
2931
class DoctrineTestHelper
3032
{
@@ -33,14 +35,18 @@ class DoctrineTestHelper
3335
*
3436
* @return EntityManager
3537
*/
36-
public static function createTestEntityManager(Configuration $config = null)
38+
public static function createTestEntityManager(Configuration $config = null/*, bool $deprecate = true*/)
3739
{
3840
if (!\extension_loaded('pdo_sqlite')) {
3941
TestCase::markTestSkipped('Extension pdo_sqlite is required.');
4042
}
4143

44+
if (func_num_args() <= 1 || func_get_arg(1)) {
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 = [
@@ -54,8 +60,12 @@ public static function createTestEntityManager(Configuration $config = null)
5460
/**
5561
* @return Configuration
5662
*/
57-
public static function createTestConfiguration()
63+
public static function createTestConfiguration(/*bool $deprecate = true*/)
5864
{
65+
if (func_num_args() === 0 || func_get_arg(0)) {
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);
@@ -71,9 +81,13 @@ public static function createTestConfiguration()
7181
/**
7282
* @return Configuration
7383
*/
74-
public static function createTestConfigurationWithXmlLoader()
84+
public static function createTestConfigurationWithXmlLoader(/*bool $deprecate = true*/)
7585
{
76-
$config = static::createTestConfiguration();
86+
if (func_num_args() === 0 || func_get_arg(0)) {
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: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
/**
2020
* @author Andreas Braun <alcaeus@alcaeus.org>
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[]
@@ -31,8 +33,12 @@ final class TestRepositoryFactory implements RepositoryFactory
3133
*
3234
* @return ObjectRepository
3335
*/
34-
public function getRepository(EntityManagerInterface $entityManager, $entityName)
36+
public function getRepository(EntityManagerInterface $entityManager, $entityName, bool $deprecate = true)
3537
{
38+
if ($deprecate) {
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])) {
@@ -42,8 +48,12 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName
4248
return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName);
4349
}
4450

45-
public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository)
51+
public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository, bool $deprecate = true)
4652
{
53+
if ($deprecate) {
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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Bridge\Doctrine\Test\DoctrineTestHelper as TestDoctrineTestHelper;
16+
17+
/**
18+
* Provides utility functions needed in tests.
19+
*
20+
* @author Bernhard Schussek <bschussek@gmail.com>
21+
*/
22+
class DoctrineTestHelper extends TestDoctrineTestHelper
23+
{
24+
public static function createTestEntityManager(Configuration $config = null)
25+
{
26+
return parent::createTestEntityManager($config, false);
27+
}
28+
29+
public static function createTestConfiguration()
30+
{
31+
return parent::createTestConfiguration(false);
32+
}
33+
34+
public static function createTestConfigurationWithXmlLoader()
35+
{
36+
return parent::createTestConfigurationWithXmlLoader(false);
37+
}
38+
}

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 <fabien@symfony.com>
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 <alcaeus@alcaeus.org>
20+
*/
21+
final class TestRepositoryFactory extends TestTestRepositoryFactory
22+
{
23+
public function getRepository(EntityManagerInterface $entityManager, $entityName, bool $deprecate = false)
24+
{
25+
return parent::getRepository($entityManager, $entityName, $deprecate);
26+
}
27+
28+
public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository, bool $deprecate = false)
29+
{
30+
return parent::setRepository($entityManager, $entityName, $repository, $deprecate);
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,8 @@
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;
22+
use Symfony\Bridge\Doctrine\Tests\TestRepositoryFactory;
2323
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
2424
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2;
2525
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy