File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
tests/Doctrine/Tests/ORM/Functional Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 88use Doctrine \Common \Collections \AbstractLazyCollection ;
99use Doctrine \Common \Collections \Criteria ;
1010use Doctrine \Common \Collections \Selectable ;
11+ use Doctrine \Common \Persistence \PersistentObject ;
1112use Doctrine \DBAL \LockMode ;
1213use Doctrine \Deprecations \Deprecation ;
1314use Doctrine \Inflector \Inflector ;
1415use Doctrine \Inflector \InflectorFactory ;
16+ use Doctrine \ORM \Exception \NotSupported ;
1517use Doctrine \ORM \Mapping \ClassMetadata ;
1618use Doctrine \ORM \Query \ResultSetMappingBuilder ;
1719use Doctrine \ORM \Repository \Exception \InvalidMagicMethodCall ;
1820use Doctrine \Persistence \ObjectRepository ;
1921
2022use function array_slice ;
23+ use function class_exists ;
2124use function lcfirst ;
2225use function sprintf ;
2326use function str_starts_with ;
@@ -168,6 +171,13 @@ public function clear()
168171 __METHOD__
169172 );
170173
174+ if (! class_exists (PersistentObject::class)) {
175+ throw NotSupported::createForPersistence3 (sprintf (
176+ 'Partial clearing of entities for class %s ' ,
177+ $ this ->_class ->rootEntityName
178+ ));
179+ }
180+
171181 $ this ->_em ->clear ($ this ->_class ->rootEntityName );
172182 }
173183
Original file line number Diff line number Diff line change 44
55namespace Doctrine \ORM \Exception ;
66
7+ use function sprintf ;
8+
79final class NotSupported extends ORMException
810{
911 public static function create (): self
@@ -15,4 +17,16 @@ public static function createForDbal3(): self
1517 {
1618 return new self ('Feature was deprecated in doctrine/dbal 2.x and is not supported by installed doctrine/dbal:3.x, please see the doctrine/deprecations logs for new alternative approaches. ' );
1719 }
20+
21+ public static function createForPersistence3 (string $ context ): self
22+ {
23+ return new self (sprintf (
24+ <<<'EXCEPTION'
25+ Context: %s
26+ Problem: Feature was deprecated in doctrine/persistence 2.x and is not supported by installed doctrine/persistence:3.x
27+ Solution: See the doctrine/deprecations logs for new alternative approaches.
28+ EXCEPTION,
29+ $ context
30+ ));
31+ }
1832}
Original file line number Diff line number Diff line change 77use BadMethodCallException ;
88use Doctrine \Common \Collections \ArrayCollection ;
99use Doctrine \Common \Collections \Criteria ;
10+ use Doctrine \Common \Persistence \PersistentObject ;
1011use Doctrine \DBAL \Connection ;
1112use Doctrine \DBAL \LockMode ;
1213use Doctrine \DBAL \Logging \Middleware as LoggingMiddleware ;
1314use Doctrine \DBAL \ParameterType ;
1415use Doctrine \Deprecations \PHPUnit \VerifyDeprecations ;
1516use Doctrine \ORM \EntityRepository ;
1617use Doctrine \ORM \Exception \InvalidEntityRepository ;
18+ use Doctrine \ORM \Exception \NotSupported ;
1719use Doctrine \ORM \Exception \ORMException ;
1820use Doctrine \ORM \Exception \UnrecognizedIdentifierFields ;
1921use Doctrine \ORM \Mapping \MappingException ;
@@ -1155,7 +1157,12 @@ public function testDeprecatedClear(): void
11551157 {
11561158 $ repository = $ this ->_em ->getRepository (CmsAddress::class);
11571159
1158- $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/issues/8460 ' );
1160+ if (class_exists (PersistentObject::class)) {
1161+ $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/issues/8460 ' );
1162+ } else {
1163+ $ this ->expectException (NotSupported::class);
1164+ $ this ->expectExceptionMessage (CmsAddress::class);
1165+ }
11591166
11601167 $ repository ->clear ();
11611168 }
You can’t perform that action at this time.
0 commit comments