Skip to content

Commit

Permalink
bug #71 Autowire defaultBuild argument when it is not disabled (larzu…
Browse files Browse the repository at this point in the history
…k91)

This PR was merged into the master branch.

Discussion
----------

Autowire defaultBuild argument when it is not disabled

Closes #70

Commits
-------

6dd09de Autowire defaultBuild argument when it is not disabled
  • Loading branch information
weaverryan committed Jul 1, 2019
2 parents f0f4244 + 6dd09de commit dcec167
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/DependencyInjection/WebpackEncoreExtension.php
Expand Up @@ -39,6 +39,9 @@ public function load(array $configs, ContainerBuilder $container)
if (false !== $config['output_path']) {
$factories['_default'] = $this->entrypointFactory($container, '_default', $config['output_path'], $config['cache'], $config['strict_mode']);
$cacheKeys['_default'] = $config['output_path'].'/'.self::ENTRYPOINTS_FILE_NAME;

$container->getDefinition('webpack_encore.entrypoint_lookup_collection')
->setArgument(1, '_default');
}

foreach ($config['builds'] as $name => $path) {
Expand Down
16 changes: 16 additions & 0 deletions tests/IntegrationTest.php
Expand Up @@ -163,6 +163,19 @@ public function testPreload()
$response = $kernel->handle($request);
$this->assertContains('</build/file1.js>; rel="preload"; as="script"', $response->headers->get('Link'));
}

public function testAutowireDefaultBuildArgument()
{
$kernel = new WebpackEncoreIntegrationTestKernel(true);
$kernel->boot();
$container = $kernel->getContainer();

$container->get('public.webpack_encore.entrypoint_lookup_collection')
->getEntrypointLookup();

// Testing that it doesn't throw an exception is enough
$this->assertTrue(true);
}
}

class WebpackEncoreIntegrationTestKernel extends Kernel
Expand Down Expand Up @@ -231,6 +244,9 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
$container->setAlias(new Alias('public.webpack_encore.tag_renderer', true), 'webpack_encore.tag_renderer');
$container->getAlias('public.webpack_encore.tag_renderer')->setPrivate(false);

$container->setAlias(new Alias('public.webpack_encore.entrypoint_lookup_collection', true), 'webpack_encore.entrypoint_lookup_collection');
$container->getAlias('public.webpack_encore.entrypoint_lookup_collection')->setPrivate(false);

// avoid logging request logs
$container->register('logger', Logger::class)
->setArgument(0, LogLevel::EMERGENCY);
Expand Down

0 comments on commit dcec167

Please sign in to comment.