Skip to content

Commit e23e9d3

Browse files
committed
bug #52 Fixing one more bug with caching system and strengthening test (weaverryan)
This PR was merged into the master branch. Discussion ---------- Fixing one more bug with caching system and strengthening test Follows up on #50 Commits ------- f21b303 Fixing one more bug with caching system and strengthening test
2 parents 488c274 + f21b303 commit e23e9d3

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/CacheWarmer/EntrypointCacheWarmer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
4444
// ignore exception
4545
}
4646
}
47+
48+
return true;
4749
}
4850
}

src/Resources/config/services.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
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-
4139
<service id="webpack_encore.cache" class="Symfony\Component\Cache\Adapter\PhpArrayAdapter">
4240
<factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" />
4341
<argument>%kernel.cache_dir%/webpack_encore.cache.php</argument>

tests/IntegrationTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Symfony\WebpackEncoreBundle\Tests;
44

5+
use Symfony\Component\DependencyInjection\Reference;
56
use Symfony\WebpackEncoreBundle\CacheWarmer\EntrypointCacheWarmer;
67
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;
78
use PHPUnit\Framework\TestCase;
@@ -81,15 +82,19 @@ public function testEntriesAreNotRepeteadWhenAlreadyOutputIntegration()
8182

8283
public function testCacheWarmer()
8384
{
84-
$kernal = new WebpackEncoreIntegrationTestKernel(true);
85-
$kernal->boot();
86-
$container = $kernal->getContainer();
85+
$kernel = new WebpackEncoreIntegrationTestKernel(true);
86+
$kernel->boot();
87+
$container = $kernel->getContainer();
8788

88-
$cacheWarmer = $container->get(CacheWarmerTester::class);
89+
$cacheWarmer = $container->get(WebpackEncoreCacheWarmerTester::class);
8990

90-
$cacheWarmer->warmCache($kernal->getCacheDir());
91+
$cacheWarmer->warmCache($kernel->getCacheDir());
9192

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]);
9398
}
9499
}
95100

@@ -137,7 +142,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
137142
]
138143
]);
139144

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);
141148
});
142149
}
143150

@@ -152,7 +159,7 @@ public function getLogDir()
152159
}
153160
}
154161

155-
class CacheWarmerTester
162+
class WebpackEncoreCacheWarmerTester
156163
{
157164
private $entrypointCacheWarmer;
158165

0 commit comments

Comments
 (0)