88use Doctrine \ODM \PHPCR \Configuration ;
99use Doctrine \ODM \PHPCR \DocumentManager ;
1010use Doctrine \ODM \PHPCR \Mapping \Driver \AnnotationDriver as DoctrinePHPCRDriver ;
11+ use Doctrine \ODM \PHPCR \Mapping \Driver \AttributeDriver as AttributeDoctrinePHPCRDriver ;
1112use Doctrine \Persistence \ManagerRegistry ;
1213use JMS \Serializer \Metadata \Driver \AnnotationDriver ;
14+ use JMS \Serializer \Metadata \Driver \AnnotationOrAttributeDriver ;
1315use JMS \Serializer \Metadata \Driver \DoctrinePHPCRTypeDriver ;
1416use JMS \Serializer \Naming \IdenticalPropertyNamingStrategy ;
1517use JMS \Serializer \Tests \Fixtures \BlogPost ;
@@ -101,10 +103,15 @@ protected function getDocumentManager()
101103 $ config = new Configuration ();
102104 $ config ->setProxyDir (sys_get_temp_dir () . '/JMSDoctrineTestProxies ' );
103105 $ config ->setProxyNamespace ('JMS\Tests\Proxies ' );
104- assert (class_exists (DoctrinePHPCRDriver::class));
105- $ config ->setMetadataDriverImpl (
106- new DoctrinePHPCRDriver (new AnnotationReader (), __DIR__ . '/../../Fixtures/DoctrinePHPCR ' ),
107- );
106+ if (class_exists (DoctrinePHPCRDriver::class)) {
107+ $ config ->setMetadataDriverImpl (
108+ new DoctrinePHPCRDriver (new AnnotationReader (), __DIR__ . '/../../Fixtures/DoctrinePHPCR ' ),
109+ );
110+ } else {
111+ $ config ->setMetadataDriverImpl (
112+ new AttributeDoctrinePHPCRDriver ([__DIR__ . '/../../Fixtures/DoctrinePHPCR ' ]),
113+ );
114+ }
108115
109116 $ session = $ this ->getMockBuilder (SessionInterface::class)->getMock ();
110117
@@ -113,7 +120,11 @@ protected function getDocumentManager()
113120
114121 public function getAnnotationDriver ()
115122 {
116- return new AnnotationDriver (new AnnotationReader (), new IdenticalPropertyNamingStrategy ());
123+ if (class_exists (DoctrinePHPCRDriver::class)) {
124+ return new AnnotationDriver (new AnnotationReader (), new IdenticalPropertyNamingStrategy ());
125+ } else {
126+ return new AnnotationOrAttributeDriver (new IdenticalPropertyNamingStrategy ());
127+ }
117128 }
118129
119130 protected function getDoctrinePHPCRDriver ()
0 commit comments