|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the Doctrine Behavioral Extensions package. |
| 7 | + * (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org |
| 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 Gedmo\Tests\Mapping; |
| 13 | + |
| 14 | +use Doctrine\Common\Annotations\AnnotationReader; |
| 15 | +use Doctrine\Common\EventManager; |
| 16 | +use Doctrine\Deprecations\Deprecation; |
| 17 | +use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; |
| 18 | +use Doctrine\ORM\EntityManager; |
| 19 | +use Doctrine\ORM\Mapping\Driver\AnnotationDriver; |
| 20 | +use Doctrine\Persistence\Reflection\TypedNoDefaultReflectionPropertyBase; |
| 21 | +use Gedmo\Sluggable\SluggableListener; |
| 22 | +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; |
| 23 | + |
| 24 | +final class MappingEventSubscriberTest extends ORMMappingTestCase |
| 25 | +{ |
| 26 | + use VerifyDeprecations; |
| 27 | + use ExpectDeprecationTrait; |
| 28 | + |
| 29 | + /** |
| 30 | + * @var EntityManager |
| 31 | + */ |
| 32 | + private $em; |
| 33 | + |
| 34 | + protected function setUp(): void |
| 35 | + { |
| 36 | + parent::setUp(); |
| 37 | + |
| 38 | + $config = $this->getBasicConfiguration(); |
| 39 | + |
| 40 | + $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader())); |
| 41 | + |
| 42 | + $conn = [ |
| 43 | + 'driver' => 'pdo_sqlite', |
| 44 | + 'memory' => true, |
| 45 | + ]; |
| 46 | + |
| 47 | + $this->em = EntityManager::create($conn, $config, new EventManager()); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @group legacy |
| 52 | + */ |
| 53 | + public function testGetConfigurationCachedFromDoctrine(): void |
| 54 | + { |
| 55 | + // doctrine/persistence changed from trigger_error to doctrine/deprecations in 2.2.1. In 2.2.2 this trait was |
| 56 | + // added, this is used to know if the doctrine/persistence version is using trigger_error or |
| 57 | + // doctrine/deprecations. This "if" check can be removed once we drop support for doctrine/persistence < 2.2.1 |
| 58 | + if (trait_exists(TypedNoDefaultReflectionPropertyBase::class)) { |
| 59 | + Deprecation::enableWithTriggerError(); |
| 60 | + |
| 61 | + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/persistence/issues/184'); |
| 62 | + } else { |
| 63 | + $this->expectDeprecation('Doctrine\Persistence\Mapping\AbstractClassMetadataFactory::getCacheDriver is deprecated. Use getCache() instead.'); |
| 64 | + } |
| 65 | + |
| 66 | + $subscriber = new SluggableListener(); |
| 67 | + $subscriber->getExtensionMetadataFactory($this->em); |
| 68 | + } |
| 69 | + |
| 70 | + protected function getUsedEntityFixtures(): array |
| 71 | + { |
| 72 | + return []; |
| 73 | + } |
| 74 | +} |
0 commit comments