Skip to content

Commit 7f6e111

Browse files
authored
Merge branch 'master' into multiple_builds_cache_keys
2 parents b22f685 + 80e71d8 commit 7f6e111

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/Resources/config/services.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
<argument type="service" id="cache.webpack_encore" />
3737
</service>
3838

39+
<service id="Symfony\WebpackEncoreBundle\CacheWarmer\EntrypointCacheWarmer" alias="webpack_encore.entrypoint_lookup.cache_warmer" />
40+
3941
<service id="webpack_encore.cache" class="Symfony\Component\Cache\Adapter\PhpArrayAdapter">
4042
<factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" />
4143
<argument>%kernel.cache_dir%/webpack_encore.cache.php</argument>

tests/IntegrationTest.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Symfony\WebpackEncoreBundle\Tests;
44

5+
use Symfony\WebpackEncoreBundle\CacheWarmer\EntrypointCacheWarmer;
56
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;
67
use PHPUnit\Framework\TestCase;
78
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
@@ -77,6 +78,19 @@ public function testEntriesAreNotRepeteadWhenAlreadyOutputIntegration()
7778
$html2
7879
);
7980
}
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+
}
8094
}
8195

8296
class WebpackEncoreIntegrationTestKernel extends Kernel
@@ -117,11 +131,13 @@ public function registerContainerConfiguration(LoaderInterface $loader)
117131

118132
$container->loadFromExtension('webpack_encore', [
119133
'output_path' => __DIR__.'/fixtures/build',
120-
'cache' => false,
134+
'cache' => true,
121135
'builds' => [
122136
'different_build' => __DIR__.'/fixtures/different_build'
123137
]
124138
]);
139+
140+
$container->autowire(CacheWarmerTester::class)->setPublic(true);
125141
});
126142
}
127143

@@ -135,3 +151,18 @@ public function getLogDir()
135151
return sys_get_temp_dir().'/logs'.spl_object_hash($this);
136152
}
137153
}
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

Comments
 (0)