Skip to content

Commit 10acbc0

Browse files
committed
feature #80 Allow Symfony 5 (nicolas-grekas)
This PR was merged into the master branch. Discussion ---------- Allow Symfony 5 Commits ------- 6970a17 Allow Symfony 5
2 parents 8666b66 + 6970a17 commit 10acbc0

13 files changed

+105
-114
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ composer.lock
22
phpunit.xml
33
vendor/
44
.php_cs.cache
5+
.phpunit.result.cache

.php_cs.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ return PhpCsFixer\Config::create()
1313
->setRules(array(
1414
'@Symfony' => true,
1515
'@Symfony:risky' => true,
16+
'@PHPUnit75Migration:risky' => true,
1617
'array_syntax' => ['syntax' => 'short'],
1718
'protected_to_private' => false,
1819
'semicolon_after_instruction' => false,

.travis.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,28 @@ env:
99
global:
1010
- PHPUNIT_FLAGS="-v"
1111
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
12+
- SYMFONY_REQUIRE='>=2.8'
1213

1314
matrix:
1415
fast_finish: true
1516
include:
1617
- php: 7.1
17-
env: SYMFONY_PHPUNIT_VERSION=7.4
18-
- php: 7.1
19-
env: deps=high SYMFONY_PHPUNIT_VERSION=7.4
2018
- php: 7.2
21-
env: deps=low
2219
- php: 7.3
23-
24-
allow_failures:
25-
# Dev-master is allowed to fail.
26-
- env: STABILITY="dev"
20+
env: deps=low
2721

2822
before_install:
29-
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
30-
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
23+
- phpenv config-rm xdebug.ini || true
24+
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
25+
26+
install:
3127
- |
32-
# Install symfony/flex
3328
if [[ $deps = low ]]; then
34-
export SYMFONY_REQUIRE='>=2.3'
29+
export SYMFONY_DEPRECATIONS_HELPER=weak
30+
composer update --prefer-dist --prefer-lowest --prefer-stable
31+
else
32+
composer update --prefer-dist
3533
fi
36-
composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
37-
38-
install:
39-
- composer install
4034
- ./vendor/bin/simple-phpunit install
4135

4236
script:

composer.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@
1919
"Symfony\\WebpackEncoreBundle\\Tests\\": "tests/"
2020
}
2121
},
22+
"minimum-stability": "dev",
2223
"require": {
2324
"php": "^7.1.3",
24-
"symfony/asset": "^3.4 || ^4.0",
25-
"symfony/config": "^3.4 || ^4.0",
26-
"symfony/dependency-injection": "^3.4 || ^4.0",
27-
"symfony/http-kernel": "^3.4 || ^4.0",
25+
"symfony/asset": "^3.4 || ^4.0 || ^5.0",
26+
"symfony/config": "^3.4 || ^4.0 || ^5.0",
27+
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0",
28+
"symfony/http-kernel": "^3.4 || ^4.0 || ^5.0",
2829
"symfony/service-contracts": "^1.0"
2930
},
3031
"require-dev": {
31-
"friendsofphp/php-cs-fixer": "^2.14",
32-
"symfony/framework-bundle": "^3.4 || ^4.0",
33-
"symfony/phpunit-bridge": "^3.4 || ^4.1",
34-
"symfony/twig-bundle": "^3.4 || ^4.0",
35-
"twig/twig": "^1.35 || ^2.0",
36-
"symfony/web-link": "^3.4 || ^4.0",
32+
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0",
33+
"symfony/phpunit-bridge": "^4.3.5 || ^5.0",
34+
"symfony/twig-bundle": "^3.4 || ^4.0 || ^5.0",
35+
"symfony/web-link": "^3.4 || ^4.0 || ^5.0",
3736
"fig/link-util": "^1.0"
3837
},
3938
"extra": {

phpunit.xml.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
backupGlobals="false"
77
bootstrap="vendor/autoload.php"
88
colors="true"
9+
failOnRisky="true"
10+
failOnWarning="true"
911
>
12+
<php>
13+
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
14+
</php>
15+
1016
<testsuites>
1117
<testsuite name="Project Test Suite">
1218
<directory>tests</directory>

src/Asset/EntrypointLookupCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
namespace Symfony\WebpackEncoreBundle\Asset;
1111

12-
use Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException;
1312
use Psr\Container\ContainerInterface;
13+
use Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException;
1414

1515
/**
1616
* Aggregate the different entry points configured in the container.

src/DependencyInjection/WebpackEncoreExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function entrypointFactory(ContainerBuilder $container, string $name, st
8686
$strictMode,
8787
];
8888
$definition = new Definition(EntrypointLookup::class, $arguments);
89-
$definition->addTag('kernel.reset', ['method'=>'reset']);
89+
$definition->addTag('kernel.reset', ['method' => 'reset']);
9090
$container->setDefinition($id, $definition);
9191

9292
return new Reference($id);

src/EventListener/PreLoadAssetsEventListener.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Fig\Link\GenericLinkProvider;
1313
use Fig\Link\Link;
1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
15+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1616
use Symfony\WebpackEncoreBundle\Asset\TagRenderer;
1717

1818
/**
@@ -27,7 +27,10 @@ public function __construct(TagRenderer $tagRenderer)
2727
$this->tagRenderer = $tagRenderer;
2828
}
2929

30-
public function onKernelResponse(FilterResponseEvent $event)
30+
/**
31+
* @param ResponseEvent $event
32+
*/
33+
public function onKernelResponse($event)
3134
{
3235
if (!$event->isMasterRequest()) {
3336
return;

tests/Asset/EntrypointLookupCollectionTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,27 @@
99

1010
namespace Symfony\WebpackEncoreBundle\Tests\Asset;
1111

12+
use PHPUnit\Framework\TestCase;
1213
use Symfony\Component\DependencyInjection\ServiceLocator;
1314
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection;
14-
use PHPUnit\Framework\TestCase;
1515
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;
1616

1717
class EntrypointLookupCollectionTest extends TestCase
1818
{
19-
/**
20-
* @expectedException \Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException
21-
* @expectedExceptionMessage The build "something" is not configured
22-
*/
2319
public function testExceptionOnMissingEntry()
2420
{
21+
$this->expectException(\Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException::class);
22+
$this->expectExceptionMessage('The build "something" is not configured');
23+
2524
$collection = new EntrypointLookupCollection(new ServiceLocator([]));
2625
$collection->getEntrypointLookup('something');
2726
}
2827

29-
/**
30-
* @expectedException \Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException
31-
* @expectedExceptionMessage There is no default build configured: please pass an argument to getEntrypointLookup().
32-
*/
3328
public function testExceptionOnMissingDefaultBuildEntry()
3429
{
30+
$this->expectException(\Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException::class);
31+
$this->expectExceptionMessage('There is no default build configured: please pass an argument to getEntrypointLookup().');
32+
3533
$collection = new EntrypointLookupCollection(new ServiceLocator([]));
3634
$collection->getEntrypointLookup();
3735
}

tests/Asset/EntrypointLookupTest.php

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
namespace Symfony\WebpackEncoreBundle\Tests\Asset;
1111

12+
use PHPUnit\Framework\TestCase;
1213
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1314
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookup;
14-
use PHPUnit\Framework\TestCase;
1515

1616
class EntrypointLookupTest extends TestCase
1717
{
@@ -45,7 +45,7 @@ class EntrypointLookupTest extends TestCase
4545
}
4646
EOF;
4747

48-
public function setUp()
48+
protected function setUp(): void
4949
{
5050
$filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle');
5151
file_put_contents($filename, self::$testJson);
@@ -119,57 +119,52 @@ public function testMissingIntegrityData()
119119
$this->assertEquals([], $this->entrypointLookup->getIntegrityData());
120120
}
121121

122-
/**
123-
* @expectedException \InvalidArgumentException
124-
* @expectedExceptionMessageContains There was a problem JSON decoding the
125-
*/
126122
public function testExceptionOnInvalidJson()
127123
{
124+
$this->expectException(\InvalidArgumentException::class);
125+
$this->expectExceptionMessage('There was a problem JSON decoding the');
126+
128127
$filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle');
129128
file_put_contents($filename, 'abcd');
130129

131130
$this->entrypointLookup = new EntrypointLookup($filename);
132131
$this->entrypointLookup->getJavaScriptFiles('an_entry');
133132
}
134133

135-
/**
136-
* @expectedException \InvalidArgumentException
137-
* @expectedExceptionMessageContains Could not find an "entrypoints" key in the
138-
*/
139134
public function testExceptionOnMissingEntrypointsKeyInJson()
140135
{
136+
$this->expectException(\InvalidArgumentException::class);
137+
$this->expectExceptionMessage('Could not find an "entrypoints" key in the');
138+
141139
$filename = tempnam(sys_get_temp_dir(), 'WebpackEncoreBundle');
142140
file_put_contents($filename, '{}');
143141

144142
$this->entrypointLookup = new EntrypointLookup($filename);
145143
$this->entrypointLookup->getJavaScriptFiles('an_entry');
146144
}
147145

148-
/**
149-
* @expectedException \InvalidArgumentException
150-
* @expectedExceptionMessage Could not find the entrypoints file
151-
*/
152146
public function testExceptionOnBadFilename()
153147
{
148+
$this->expectException(\InvalidArgumentException::class);
149+
$this->expectExceptionMessage('Could not find the entrypoints file');
150+
154151
$entrypointLookup = new EntrypointLookup('fake_file');
155152
$entrypointLookup->getCssFiles('anything');
156153
}
157154

158-
/**
159-
* @expectedException \Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException
160-
* @expectedExceptionMessage Could not find the entry
161-
*/
162155
public function testExceptionOnMissingEntry()
163156
{
157+
$this->expectException(\Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException::class);
158+
$this->expectExceptionMessage('Could not find the entry');
159+
164160
$this->entrypointLookup->getCssFiles('fake_entry');
165161
}
166162

167-
/**
168-
* @expectedException \Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException
169-
* @expectedExceptionMessage Try "my_entry" instead
170-
*/
171163
public function testExceptionOnEntryWithExtension()
172164
{
165+
$this->expectException(\Symfony\WebpackEncoreBundle\Exception\EntrypointNotFoundException::class);
166+
$this->expectExceptionMessage('Try "my_entry" instead');
167+
173168
$this->entrypointLookup->getJavaScriptFiles('my_entry.js');
174169
}
175170

0 commit comments

Comments
 (0)