Skip to content

Commit ecad299

Browse files
authored
Merge branch 'master' into patch-1
2 parents 04d8091 + 6f28251 commit ecad299

File tree

6 files changed

+48
-19
lines changed

6 files changed

+48
-19
lines changed

.php_cs.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (!file_exists(__DIR__.'/src')) {
66

77
$finder = PhpCsFixer\Finder::create()
88
->in(__DIR__.'/src')
9+
->in(__DIR__.'/tests')
910
;
1011

1112
return PhpCsFixer\Config::create()

src/DependencyInjection/WebpackEncoreExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public function load(array $configs, ContainerBuilder $container)
5050

5151
$container->getDefinition('webpack_encore.entrypoint_lookup_collection')
5252
->replaceArgument(0, ServiceLocatorTagPass::register($container, $factories));
53-
$container->setAlias(EntrypointLookupInterface::class, new Alias($this->getEntrypointServiceId('_default')));
53+
if (false !== $config['output_path']) {
54+
$container->setAlias(EntrypointLookupInterface::class, new Alias($this->getEntrypointServiceId('_default')));
55+
}
5456

5557
$defaultAttributes = [];
5658

tests/Asset/EntrypointLookupCollectionTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony WebpackEncoreBundle package.
5+
* (c) Fabien Potencier <[email protected]>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
310
namespace Symfony\WebpackEncoreBundle\Tests\Asset;
411

512
use Symfony\Component\DependencyInjection\ServiceLocator;
@@ -10,7 +17,7 @@
1017
class EntrypointLookupCollectionTest extends TestCase
1118
{
1219
/**
13-
* @expectedException Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException
20+
* @expectedException \Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException
1421
* @expectedExceptionMessage The build "something" is not configured
1522
*/
1623
public function testExceptionOnMissingEntry()
@@ -20,7 +27,7 @@ public function testExceptionOnMissingEntry()
2027
}
2128

2229
/**
23-
* @expectedException Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException
30+
* @expectedException \Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException
2431
* @expectedExceptionMessage There is no default build configured: please pass an argument to getEntrypointLookup().
2532
*/
2633
public function testExceptionOnMissingDefaultBuildEntry()
@@ -32,7 +39,7 @@ public function testExceptionOnMissingDefaultBuildEntry()
3239
public function testDefaultBuildIsReturned()
3340
{
3441
$lookup = $this->createMock(EntrypointLookupInterface::class);
35-
$collection = new EntrypointLookupCollection(new ServiceLocator(['the_default' => function() use ($lookup) { return $lookup; }]), 'the_default');
42+
$collection = new EntrypointLookupCollection(new ServiceLocator(['the_default' => function () use ($lookup) { return $lookup; }]), 'the_default');
3643

3744
$this->assertSame($lookup, $collection->getEntrypointLookup());
3845
}

tests/Asset/EntrypointLookupTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony WebpackEncoreBundle package.
5+
* (c) Fabien Potencier <[email protected]>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
310
namespace Symfony\WebpackEncoreBundle\Tests\Asset;
411

512
use Symfony\Component\Cache\Adapter\ArrayAdapter;
6-
use Symfony\Component\Cache\Adapter\NullAdapter;
713
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookup;
814
use PHPUnit\Framework\TestCase;
9-
use Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException;
1015

1116
class EntrypointLookupTest extends TestCase
1217
{
@@ -121,7 +126,7 @@ public function testMissingIntegrityData()
121126
public function testExceptionOnInvalidJson()
122127
{
123128
$filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle');
124-
file_put_contents($filename, "abcd");
129+
file_put_contents($filename, 'abcd');
125130

126131
$this->entrypointLookup = new EntrypointLookup($filename);
127132
$this->entrypointLookup->getJavaScriptFiles('an_entry');
@@ -134,7 +139,7 @@ public function testExceptionOnInvalidJson()
134139
public function testExceptionOnMissingEntrypointsKeyInJson()
135140
{
136141
$filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle');
137-
file_put_contents($filename, "{}");
142+
file_put_contents($filename, '{}');
138143

139144
$this->entrypointLookup = new EntrypointLookup($filename);
140145
$this->entrypointLookup->getJavaScriptFiles('an_entry');
@@ -151,7 +156,7 @@ public function testExceptionOnBadFilename()
151156
}
152157

153158
/**
154-
* @expectedException Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException
159+
* @expectedException \Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException
155160
* @expectedExceptionMessage Could not find the entry
156161
*/
157162
public function testExceptionOnMissingEntry()
@@ -160,7 +165,7 @@ public function testExceptionOnMissingEntry()
160165
}
161166

162167
/**
163-
* @expectedException Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException
168+
* @expectedException \Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException
164169
* @expectedExceptionMessage Try "my_entry" instead
165170
*/
166171
public function testExceptionOnEntryWithExtension()

tests/Asset/TagRendererTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony WebpackEncoreBundle package.
5+
* (c) Fabien Potencier <[email protected]>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
310
namespace Symfony\WebpackEncoreBundle\Tests\Asset;
411

512
use PHPUnit\Framework\TestCase;
@@ -30,7 +37,7 @@ public function testRenderScriptTagsWithDefaultAttributes()
3037
['/build/file1.js', 'custom_package'],
3138
['/build/file2.js', 'custom_package']
3239
)
33-
->willReturnCallback(function($path) {
40+
->willReturnCallback(function ($path) {
3441
return 'http://localhost:8080'.$path;
3542
});
3643
$renderer = new TagRenderer($entrypointCollection, $packages, []);
@@ -61,7 +68,7 @@ public function testRenderScriptTagsWithBadFilename()
6168
$packages = $this->createMock(Packages::class);
6269
$packages->expects($this->once())
6370
->method('getUrl')
64-
->willReturnCallback(function($path) {
71+
->willReturnCallback(function ($path) {
6572
return 'http://localhost:8080'.$path;
6673
});
6774
$renderer = new TagRenderer($entrypointCollection, $packages, ['crossorigin'=>'anonymous']);
@@ -107,7 +114,7 @@ public function testRenderScriptTagsWithinAnEntryPointCollection()
107114
['/build/file2.js', null],
108115
['/build/file3.js', 'specific_package']
109116
)
110-
->willReturnCallback(function($path) {
117+
->willReturnCallback(function ($path) {
111118
return 'http://localhost:8080'.$path;
112119
});
113120
$renderer = new TagRenderer($entrypointCollection, $packages, ['crossorigin'=>'anonymous']);
@@ -158,7 +165,7 @@ public function testRenderScriptTagsWithHashes()
158165
['/build/file2.js', 'custom_package']
159166
)
160167
->willReturnCallback(function ($path) {
161-
return 'http://localhost:8080' . $path;
168+
return 'http://localhost:8080'.$path;
162169
});
163170
$renderer = new TagRenderer($entrypointCollection, $packages, ['crossorigin'=>'anonymous']);
164171

tests/IntegrationTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony WebpackEncoreBundle package.
5+
* (c) Fabien Potencier <[email protected]>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
310
namespace Symfony\WebpackEncoreBundle\Tests;
411

512
use Symfony\Component\DependencyInjection\Reference;
@@ -28,7 +35,7 @@ public function testTwigIntegration()
2835
$html1
2936
);
3037
$this->assertContains(
31-
'<link rel="stylesheet" href="/build/styles.css" integrity="sha384-4g+Zv0iELStVvA4/B27g4TQHUMwZttA5TEojjUyB8Gl5p7sarU4y+VTSGMrNab8n">' .
38+
'<link rel="stylesheet" href="/build/styles.css" integrity="sha384-4g+Zv0iELStVvA4/B27g4TQHUMwZttA5TEojjUyB8Gl5p7sarU4y+VTSGMrNab8n">'.
3239
'<link rel="stylesheet" href="/build/styles2.css" integrity="sha384-hfZmq9+2oI5Cst4/F4YyS2tJAAYdGz7vqSMP8cJoa8bVOr2kxNRLxSw6P8UZjwUn">',
3340
$html1
3441
);
@@ -129,7 +136,7 @@ public function registerBundles()
129136

130137
public function registerContainerConfiguration(LoaderInterface $loader)
131138
{
132-
$loader->load(function(ContainerBuilder $container) {
139+
$loader->load(function (ContainerBuilder $container) {
133140
$container->loadFromExtension('framework', [
134141
'secret' => 'foo',
135142
'assets' => [
@@ -139,7 +146,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
139146

140147
$container->loadFromExtension('twig', [
141148
'paths' => [
142-
__DIR__.'/fixtures' => 'integration_test'
149+
__DIR__.'/fixtures' => 'integration_test',
143150
],
144151
'strict_variables' => true,
145152
]);
@@ -149,8 +156,8 @@ public function registerContainerConfiguration(LoaderInterface $loader)
149156
'cache' => true,
150157
'crossorigin' => false,
151158
'builds' => [
152-
'different_build' => __DIR__.'/fixtures/different_build'
153-
]
159+
'different_build' => __DIR__.'/fixtures/different_build',
160+
],
154161
]);
155162

156163
$container->register(WebpackEncoreCacheWarmerTester::class)

0 commit comments

Comments
 (0)