2
2
3
3
namespace Symfony \WebpackEncoreBundle \Tests ;
4
4
5
+ use Symfony \Component \DependencyInjection \Reference ;
5
6
use Symfony \WebpackEncoreBundle \CacheWarmer \EntrypointCacheWarmer ;
6
7
use Symfony \WebpackEncoreBundle \WebpackEncoreBundle ;
7
8
use PHPUnit \Framework \TestCase ;
@@ -81,15 +82,19 @@ public function testEntriesAreNotRepeteadWhenAlreadyOutputIntegration()
81
82
82
83
public function testCacheWarmer ()
83
84
{
84
- $ kernal = new WebpackEncoreIntegrationTestKernel (true );
85
- $ kernal ->boot ();
86
- $ container = $ kernal ->getContainer ();
85
+ $ kernel = new WebpackEncoreIntegrationTestKernel (true );
86
+ $ kernel ->boot ();
87
+ $ container = $ kernel ->getContainer ();
87
88
88
- $ cacheWarmer = $ container ->get (CacheWarmerTester ::class);
89
+ $ cacheWarmer = $ container ->get (WebpackEncoreCacheWarmerTester ::class);
89
90
90
- $ cacheWarmer ->warmCache ($ kernal ->getCacheDir ());
91
+ $ cacheWarmer ->warmCache ($ kernel ->getCacheDir ());
91
92
92
- $ this ->assertTrue (true , 'Cache warmer has successfully filled that cache and went without exceptions ' );
93
+ $ cachePath = $ kernel ->getCacheDir ().'/webpack_encore.cache.php ' ;
94
+ $ this ->assertFileExists ($ cachePath );
95
+ $ data = require $ cachePath ;
96
+ // check for both build keys
97
+ $ this ->assertEquals (['_default ' => 0 , 'different_build ' => 1 ], $ data [0 ]);
93
98
}
94
99
}
95
100
@@ -137,7 +142,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
137
142
]
138
143
]);
139
144
140
- $ container ->autowire (CacheWarmerTester::class)->setPublic (true );
145
+ $ container ->register (WebpackEncoreCacheWarmerTester::class)
146
+ ->addArgument (new Reference ('webpack_encore.entrypoint_lookup.cache_warmer ' ))
147
+ ->setPublic (true );
141
148
});
142
149
}
143
150
@@ -152,7 +159,7 @@ public function getLogDir()
152
159
}
153
160
}
154
161
155
- class CacheWarmerTester
162
+ class WebpackEncoreCacheWarmerTester
156
163
{
157
164
private $ entrypointCacheWarmer ;
158
165
0 commit comments