44
55namespace Doctrine \Tests \ORM ;
66
7+ use Doctrine \Deprecations \PHPUnit \VerifyDeprecations ;
78use Doctrine \ORM \Configuration ;
89use Doctrine \ORM \Mapping as MappingNamespace ;
910use Doctrine \ORM \Mapping \Driver \AttributeDriver ;
1213use PHPUnit \Framework \Attributes \Group ;
1314use PHPUnit \Framework \Attributes \RequiresPhpExtension ;
1415use PHPUnit \Framework \Attributes \RequiresSetting ;
16+ use PHPUnit \Framework \Attributes \WithoutErrorHandler ;
1517use PHPUnit \Framework \TestCase ;
1618use ReflectionProperty ;
1719use Symfony \Component \Cache \Adapter \AbstractAdapter ;
2022
2123use function sys_get_temp_dir ;
2224
25+ use const PHP_VERSION_ID ;
26+
2327class ORMSetupTest extends TestCase
2428{
29+ use VerifyDeprecations;
30+
31+ #[WithoutErrorHandler]
2532 public function testAttributeConfiguration (): void
2633 {
34+ if (PHP_VERSION_ID >= 80400 ) {
35+ $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/pull/12005 ' );
36+ }
37+
2738 $ config = ORMSetup::createAttributeMetadataConfiguration ([], true );
2839
2940 self ::assertInstanceOf (Configuration::class, $ config );
@@ -32,8 +43,21 @@ public function testAttributeConfiguration(): void
3243 self ::assertInstanceOf (AttributeDriver::class, $ config ->getMetadataDriverImpl ());
3344 }
3445
46+ public function testAttributeConfig (): void
47+ {
48+ $ config = ORMSetup::createAttributeMetadataConfig ([], true );
49+
50+ self ::assertInstanceOf (Configuration::class, $ config );
51+ self ::assertInstanceOf (AttributeDriver::class, $ config ->getMetadataDriverImpl ());
52+ }
53+
54+ #[WithoutErrorHandler]
3555 public function testXMLConfiguration (): void
3656 {
57+ if (PHP_VERSION_ID >= 80400 ) {
58+ $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/pull/12005 ' );
59+ }
60+
3761 $ config = ORMSetup::createXMLMetadataConfiguration ([], true );
3862
3963 self ::assertInstanceOf (Configuration::class, $ config );
@@ -44,14 +68,18 @@ public function testDisablingXmlValidationIsPossible(): void
4468 {
4569 $ this ->expectNotToPerformAssertions ();
4670
47- ORMSetup::createXMLMetadataConfiguration (paths: [], isXsdValidationEnabled: false );
71+ ORMSetup::createXMLMetadataConfig (paths: [], isXsdValidationEnabled: false );
4872 }
4973
5074 #[RequiresPhpExtension('apcu ' )]
5175 #[RequiresSetting('apc.enable_cli ' , '1 ' )]
5276 #[RequiresSetting('apc.enabled ' , '1 ' )]
53- public function testCacheNamespaceShouldBeGeneratedForApcu (): void
77+ public function testCacheNamespaceShouldBeGeneratedForApcuWhenUsingLegacyConstructor (): void
5478 {
79+ if (PHP_VERSION_ID >= 80400 ) {
80+ $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/pull/12005 ' );
81+ }
82+
5583 $ config = ORMSetup::createConfiguration (false , '/foo ' );
5684 $ cache = $ config ->getMetadataCache ();
5785
@@ -61,7 +89,22 @@ public function testCacheNamespaceShouldBeGeneratedForApcu(): void
6189 self ::assertSame ('dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf: ' , $ namespaceProperty ->getValue ($ cache ));
6290 }
6391
92+ #[RequiresPhpExtension('apcu ' )]
93+ #[RequiresSetting('apc.enable_cli ' , '1 ' )]
94+ #[RequiresSetting('apc.enabled ' , '1 ' )]
95+ public function testCacheNamespaceShouldBeGeneratedForApcu (): void
96+ {
97+ $ config = ORMSetup::createConfig (false , '/foo ' );
98+ $ cache = $ config ->getMetadataCache ();
99+
100+ $ namespaceProperty = new ReflectionProperty (AbstractAdapter::class, 'namespace ' );
101+
102+ self ::assertInstanceOf (ApcuAdapter::class, $ cache );
103+ self ::assertSame ('dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf: ' , $ namespaceProperty ->getValue ($ cache ));
104+ }
105+
64106 #[Group('DDC-1350 ' )]
107+ #[WithoutErrorHandler]
65108 public function testConfigureProxyDir (): void
66109 {
67110 $ config = ORMSetup::createAttributeMetadataConfiguration ([], true , '/foo ' );
@@ -72,7 +115,7 @@ public function testConfigureProxyDir(): void
72115 public function testConfigureCache (): void
73116 {
74117 $ cache = new ArrayAdapter ();
75- $ config = ORMSetup::createAttributeMetadataConfiguration ([], true , null , $ cache );
118+ $ config = ORMSetup::createAttributeMetadataConfig ([], true , null , $ cache );
76119
77120 self ::assertSame ($ cache , $ config ->getResultCache ());
78121 self ::assertSame ($ cache , $ config ->getQueryCache ());
@@ -83,7 +126,7 @@ public function testConfigureCache(): void
83126 public function testConfigureCacheCustomInstance (): void
84127 {
85128 $ cache = new ArrayAdapter ();
86- $ config = ORMSetup::createConfiguration (true , null , $ cache );
129+ $ config = ORMSetup::createConfig (true , null , $ cache );
87130
88131 self ::assertSame ($ cache , $ config ->getResultCache ());
89132 self ::assertSame ($ cache , $ config ->getQueryCache ());
0 commit comments