@@ -29,8 +29,8 @@ public function testWarmUp(array $loaders)
29
29
$ file = sys_get_temp_dir ().'/cache-serializer.php ' ;
30
30
@unlink ($ file );
31
31
32
- $ warmer = new SerializerCacheWarmer ($ loaders , $ file );
33
- $ warmer ->warmUp (\dirname ($ file ));
32
+ $ warmer = new SerializerCacheWarmer ($ loaders , basename ( $ file) );
33
+ $ warmer ->warmUp (\dirname ($ file ), \dirname ( $ file ) );
34
34
35
35
$ this ->assertFileExists ($ file );
36
36
@@ -40,6 +40,25 @@ public function testWarmUp(array $loaders)
40
40
$ this ->assertTrue ($ arrayPool ->getItem ('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author ' )->isHit ());
41
41
}
42
42
43
+ /**
44
+ * @dataProvider loaderProvider
45
+ */
46
+ public function testWarmUpWithoutBuildDir (array $ loaders )
47
+ {
48
+ $ file = sys_get_temp_dir ().'/cache-serializer.php ' ;
49
+ @unlink ($ file );
50
+
51
+ $ warmer = new SerializerCacheWarmer ($ loaders , basename ($ file ));
52
+ $ warmer ->warmUp (\dirname ($ file ));
53
+
54
+ $ this ->assertFileDoesNotExist ($ file );
55
+
56
+ $ arrayPool = new PhpArrayAdapter ($ file , new NullAdapter ());
57
+
58
+ $ this ->assertTrue ($ arrayPool ->getItem ('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person ' )->isHit ());
59
+ $ this ->assertTrue ($ arrayPool ->getItem ('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author ' )->isHit ());
60
+ }
61
+
43
62
public static function loaderProvider (): array
44
63
{
45
64
return [
@@ -65,8 +84,8 @@ public function testWarmUpWithoutLoader()
65
84
$ file = sys_get_temp_dir ().'/cache-serializer-without-loader.php ' ;
66
85
@unlink ($ file );
67
86
68
- $ warmer = new SerializerCacheWarmer ([], $ file );
69
- $ warmer ->warmUp (\dirname ($ file ));
87
+ $ warmer = new SerializerCacheWarmer ([], basename ( $ file) );
88
+ $ warmer ->warmUp (\dirname ($ file ), \dirname ( $ file ) );
70
89
71
90
$ this ->assertFileExists ($ file );
72
91
}
@@ -79,15 +98,19 @@ public function testClassAutoloadException()
79
98
{
80
99
$ this ->assertFalse (class_exists ($ mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_SerializerCacheWarmerTest ' , false ));
81
100
82
- $ warmer = new SerializerCacheWarmer ([new YamlFileLoader (__DIR__ .'/../Fixtures/Serialization/Resources/does_not_exist.yaml ' )], tempnam (sys_get_temp_dir (), __FUNCTION__ ));
101
+ $ file = tempnam (sys_get_temp_dir (), __FUNCTION__ );
102
+ @unlink ($ file );
103
+
104
+ $ warmer = new SerializerCacheWarmer ([new YamlFileLoader (__DIR__ .'/../Fixtures/Serialization/Resources/does_not_exist.yaml ' )], basename ($ file ));
83
105
84
106
spl_autoload_register ($ classLoader = function ($ class ) use ($ mappedClass ) {
85
107
if ($ class === $ mappedClass ) {
86
108
throw new \DomainException ('This exception should be caught by the warmer. ' );
87
109
}
88
110
}, true , true );
89
111
90
- $ warmer ->warmUp ('foo ' );
112
+ $ warmer ->warmUp (\dirname ($ file ), \dirname ($ file ));
113
+ $ this ->assertFileExists ($ file );
91
114
92
115
spl_autoload_unregister ($ classLoader );
93
116
}
@@ -103,7 +126,10 @@ public function testClassAutoloadExceptionWithUnrelatedException()
103
126
104
127
$ this ->assertFalse (class_exists ($ mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_SerializerCacheWarmerTest ' , false ));
105
128
106
- $ warmer = new SerializerCacheWarmer ([new YamlFileLoader (__DIR__ .'/../Fixtures/Serialization/Resources/does_not_exist.yaml ' )], tempnam (sys_get_temp_dir (), __FUNCTION__ ));
129
+ $ file = tempnam (sys_get_temp_dir (), __FUNCTION__ );
130
+ @unlink ($ file );
131
+
132
+ $ warmer = new SerializerCacheWarmer ([new YamlFileLoader (__DIR__ .'/../Fixtures/Serialization/Resources/does_not_exist.yaml ' )], basename ($ file ));
107
133
108
134
spl_autoload_register ($ classLoader = function ($ class ) use ($ mappedClass ) {
109
135
if ($ class === $ mappedClass ) {
@@ -112,8 +138,12 @@ public function testClassAutoloadExceptionWithUnrelatedException()
112
138
}
113
139
}, true , true );
114
140
115
- $ warmer ->warmUp ('foo ' );
141
+ try {
142
+ $ warmer ->warmUp (\dirname ($ file ), \dirname ($ file ));
143
+ } finally {
144
+ $ this ->assertFileDoesNotExist ($ file );
116
145
117
- spl_autoload_unregister ($ classLoader );
146
+ spl_autoload_unregister ($ classLoader );
147
+ }
118
148
}
119
149
}
0 commit comments