2
2
3
3
namespace Symfony \WebpackEncoreBundle \Tests ;
4
4
5
+ use Symfony \WebpackEncoreBundle \CacheWarmer \EntrypointCacheWarmer ;
5
6
use Symfony \WebpackEncoreBundle \WebpackEncoreBundle ;
6
7
use PHPUnit \Framework \TestCase ;
7
8
use Symfony \Bundle \FrameworkBundle \FrameworkBundle ;
@@ -77,6 +78,19 @@ public function testEntriesAreNotRepeteadWhenAlreadyOutputIntegration()
77
78
$ html2
78
79
);
79
80
}
81
+
82
+ public function testCacheWarmer ()
83
+ {
84
+ $ kernal = new WebpackEncoreIntegrationTestKernel (true );
85
+ $ kernal ->boot ();
86
+ $ container = $ kernal ->getContainer ();
87
+
88
+ $ cacheWarmer = $ container ->get (CacheWarmerTester::class);
89
+
90
+ $ cacheWarmer ->warmCache ($ kernal ->getCacheDir ());
91
+
92
+ $ this ->assertTrue (true , 'Cache warmer has successfully filled that cache and went without exceptions ' );
93
+ }
80
94
}
81
95
82
96
class WebpackEncoreIntegrationTestKernel extends Kernel
@@ -117,11 +131,13 @@ public function registerContainerConfiguration(LoaderInterface $loader)
117
131
118
132
$ container ->loadFromExtension ('webpack_encore ' , [
119
133
'output_path ' => __DIR__ .'/fixtures/build ' ,
120
- 'cache ' => false ,
134
+ 'cache ' => true ,
121
135
'builds ' => [
122
136
'different_build ' => __DIR__ .'/fixtures/different_build '
123
137
]
124
138
]);
139
+
140
+ $ container ->autowire (CacheWarmerTester::class)->setPublic (true );
125
141
});
126
142
}
127
143
@@ -135,3 +151,18 @@ public function getLogDir()
135
151
return sys_get_temp_dir ().'/logs ' .spl_object_hash ($ this );
136
152
}
137
153
}
154
+
155
+ class CacheWarmerTester
156
+ {
157
+ private $ entrypointCacheWarmer ;
158
+
159
+ public function __construct (EntrypointCacheWarmer $ entrypointCacheWarmer )
160
+ {
161
+ $ this ->entrypointCacheWarmer = $ entrypointCacheWarmer ;
162
+ }
163
+
164
+ public function warmCache (string $ cacheDir )
165
+ {
166
+ $ this ->entrypointCacheWarmer ->warmUp ($ cacheDir );
167
+ }
168
+ }
0 commit comments