Skip to content

Commit 1590eeb

Browse files
committed
minor #60 Run php-cs-fixer over the bundle using preexisting .php_cs.dist rules (PhilETaylor)
This PR was squashed before being merged into the master branch (closes #60). Discussion ---------- Run php-cs-fixer over the bundle using preexisting .php_cs.dist rules 6th April 2019 - Run php-cs-fixer over the bundle using preexisting .php_cs.dist rules Including now the tests folder 1) tests/Asset/EntrypointLookupTest.php (single_quote, php_unit_fqcn_annotation, no_unused_imports, header_comment) 2) tests/Asset/EntrypointLookupCollectionTest.php (function_declaration, php_unit_fqcn_annotation, header_comment) 3) tests/Asset/TagRendererTest.php (concat_space, function_declaration, header_comment) 4) tests/IntegrationTest.php (concat_space, trailing_comma_in_multiline_array, function_declaration, header_comment, binary_operator_spaces) 5) src/Asset/EntrypointLookupCollectionInterface.php (phpdoc_annotation_without_dot) 6) src/Asset/EntrypointLookup.php (native_function_invocation) Commits ------- 893a004 Run php-cs-fixer over the bundle using preexisting .php_cs.dist rules
2 parents fc18456 + 893a004 commit 1590eeb

7 files changed

+47
-20
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/Asset/EntrypointLookup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getIntegrityData(): array
5050
{
5151
$entriesData = $this->getEntriesData();
5252

53-
if (!array_key_exists('integrity', $entriesData)) {
53+
if (!\array_key_exists('integrity', $entriesData)) {
5454
return [];
5555
}
5656

src/Asset/EntrypointLookupCollectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface EntrypointLookupCollectionInterface
1616
/**
1717
* Retrieve the EntrypointLookupInterface for the given build.
1818
*
19-
* @throws UndefinedBuildException If the build does not exist.
19+
* @throws UndefinedBuildException if the build does not exist
2020
*/
2121
public function getEntrypointLookup(string $buildName = null): EntrypointLookupInterface;
2222
}

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 testRenderScriptTags()
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);
@@ -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);
@@ -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, true);
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
]);
@@ -148,8 +155,8 @@ public function registerContainerConfiguration(LoaderInterface $loader)
148155
'output_path' => __DIR__.'/fixtures/build',
149156
'cache' => true,
150157
'builds' => [
151-
'different_build' => __DIR__.'/fixtures/different_build'
152-
]
158+
'different_build' => __DIR__.'/fixtures/different_build',
159+
],
153160
]);
154161

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

0 commit comments

Comments
 (0)