2020
2121class ValidatorCacheWarmerTest extends TestCase
2222{
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+
2340 public function testWarmUp ()
2441 {
2542 $ validatorBuilder = new ValidatorBuilder ();
@@ -36,7 +53,7 @@ public function testWarmUp()
3653
3754 $ this ->assertFileExists ($ file );
3855
39- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
56+ $ arrayPool = $ this -> getArrayPool ($ file );
4057
4158 $ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person ' )->isHit ());
4259 $ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author ' )->isHit ());
@@ -61,7 +78,7 @@ public function testWarmUpAbsoluteFilePath()
6178 $ this ->assertFileExists ($ file );
6279 $ this ->assertFileDoesNotExist ($ cacheDir .'/cache-validator.php ' );
6380
64- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
81+ $ arrayPool = $ this -> getArrayPool ($ file );
6582
6683 $ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person ' )->isHit ());
6784 $ this ->assertTrue ($ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author ' )->isHit ());
@@ -83,10 +100,10 @@ public function testWarmUpWithoutBuilDir()
83100
84101 $ this ->assertFileDoesNotExist ($ file );
85102
86- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
103+ $ arrayPool = $ this -> getArrayPool ($ file );
87104
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 ());
90107 }
91108
92109 public function testWarmUpWithAnnotations ()
@@ -103,7 +120,7 @@ public function testWarmUpWithAnnotations()
103120
104121 $ this ->assertFileExists ($ file );
105122
106- $ arrayPool = new PhpArrayAdapter ($ file, new NullAdapter () );
123+ $ arrayPool = $ this -> getArrayPool ($ file );
107124
108125 $ item = $ arrayPool ->getItem ('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category ' );
109126 $ this ->assertTrue ($ item ->isHit ());
0 commit comments