15
15
use Doctrine \DBAL \DriverManager ;
16
16
use Doctrine \ORM \Configuration ;
17
17
use Doctrine \ORM \EntityManager ;
18
- use Doctrine \ORM \EntityManagerInterface ;
19
18
use Doctrine \ORM \Event \LoadClassMetadataEventArgs ;
20
19
use Doctrine \ORM \Events ;
21
20
use Doctrine \ORM \Id \IdentityGenerator ;
22
21
use Doctrine \ORM \Mapping \ClassMetadata ;
23
22
use Doctrine \ORM \Mapping \Driver \AnnotationDriver ;
24
23
use Doctrine \ORM \Mapping \Driver \AttributeDriver ;
25
24
use Doctrine \ORM \Tools \SchemaTool ;
25
+ use Gedmo \Mapping \Driver \AttributeReader ;
26
26
use Gedmo \Tests \Mapping \Fixture \Unmapped \Timestampable ;
27
27
use Gedmo \Timestampable \TimestampableListener ;
28
28
use PHPUnit \Framework \TestCase ;
@@ -36,30 +36,36 @@ final class ForcedMetadataTest extends TestCase
36
36
{
37
37
private TimestampableListener $ timestampable ;
38
38
39
- private EntityManagerInterface $ em ;
39
+ private EntityManager $ em ;
40
40
41
41
protected function setUp (): void
42
42
{
43
43
$ config = new Configuration ();
44
44
$ config ->setProxyDir (TESTS_TEMP_DIR );
45
45
$ config ->setProxyNamespace ('Gedmo\Mapping\Proxy ' );
46
46
47
- if (PHP_VERSION_ID >= 80000 && class_exists (AttributeDriver::class) ) {
47
+ if (PHP_VERSION_ID >= 80000 ) {
48
48
$ config ->setMetadataDriverImpl (new AttributeDriver ([]));
49
49
} else {
50
50
$ config ->setMetadataDriverImpl (new AnnotationDriver ($ _ENV ['annotation_reader ' ]));
51
51
}
52
52
53
- $ conn = [
54
- 'driver ' => 'pdo_sqlite ' ,
55
- 'memory ' => true ,
56
- ];
53
+ $ this ->timestampable = new TimestampableListener ();
54
+
55
+ if (PHP_VERSION_ID >= 80000 ) {
56
+ $ this ->timestampable ->setAnnotationReader (new AttributeReader ());
57
+ } else {
58
+ $ this ->timestampable ->setAnnotationReader ($ _ENV ['annotation_reader ' ]);
59
+ }
57
60
58
61
$ evm = new EventManager ();
59
- $ this ->timestampable = new TimestampableListener ();
60
- $ this ->timestampable ->setAnnotationReader ($ _ENV ['annotation_reader ' ]);
61
62
$ evm ->addEventSubscriber ($ this ->timestampable );
62
- $ connection = DriverManager::getConnection ($ conn , $ config );
63
+
64
+ $ connection = DriverManager::getConnection ([
65
+ 'driver ' => 'pdo_sqlite ' ,
66
+ 'memory ' => true ,
67
+ ], $ config );
68
+
63
69
$ this ->em = new EntityManager ($ connection , $ config , $ evm );
64
70
}
65
71
@@ -72,6 +78,8 @@ public function testShouldWork(): void
72
78
$ this ->em ,
73
79
Timestampable::class
74
80
);
81
+
82
+ // @todo: This assertion fails when run in isolation
75
83
static ::assertTrue (isset ($ conf ['create ' ]));
76
84
77
85
$ test = new Timestampable ();
0 commit comments