20
20
21
21
class ValidatorCacheWarmerTest extends TestCase
22
22
{
23
+ private PhpArrayAdapter $ arrayPool ;
24
+
25
+ protected function tearDown (): void
26
+ {
27
+ parent ::tearDown ();
28
+
29
+ if (isset ($ this ->arrayPool )) {
30
+ $ this ->arrayPool ->clear ();
31
+ unset($ this ->arrayPool );
32
+ }
33
+ }
34
+
35
+ private function getArrayPool (string $ file ): PhpArrayAdapter
36
+ {
37
+ return $ this ->arrayPool = new PhpArrayAdapter ($ file , new NullAdapter ());
38
+ }
39
+
23
40
public function testWarmUp ()
24
41
{
25
42
$ validatorBuilder = new ValidatorBuilder ();
@@ -36,7 +53,7 @@ public function testWarmUp()
36
53
37
54
$ this ->assertFileExists ($ file );
38
55
39
- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
56
+ $ arrayPool = $ this -> getArrayPool ($ file );
40
57
41
58
$ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person ' )->isHit ());
42
59
$ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author ' )->isHit ());
@@ -61,7 +78,7 @@ public function testWarmUpAbsoluteFilePath()
61
78
$ this ->assertFileExists ($ file );
62
79
$ this ->assertFileDoesNotExist ($ cacheDir .'/cache-validator.php ' );
63
80
64
- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
81
+ $ arrayPool = $ this -> getArrayPool ($ file );
65
82
66
83
$ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person ' )->isHit ());
67
84
$ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author ' )->isHit ());
@@ -83,10 +100,10 @@ public function testWarmUpWithoutBuilDir()
83
100
84
101
$ this ->assertFileDoesNotExist ($ file );
85
102
86
- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
103
+ $ arrayPool = $ this -> getArrayPool ($ file );
87
104
88
- $ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person ' )->isHit ());
89
- $ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author ' )->isHit ());
105
+ $ this ->assertFalse ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person ' )->isHit ());
106
+ $ this ->assertFalse ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author ' )->isHit ());
90
107
}
91
108
92
109
public function testWarmUpWithAnnotations ()
@@ -103,7 +120,7 @@ public function testWarmUpWithAnnotations()
103
120
104
121
$ this ->assertFileExists ($ file );
105
122
106
- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
123
+ $ arrayPool = $ this -> getArrayPool ($ file );
107
124
108
125
$ item = $ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category ' );
109
126
$ this ->assertTrue ($ item ->isHit ());
0 commit comments