From 1aa2bb17eae6b65c0fe86d1864c667607fa5af84 Mon Sep 17 00:00:00 2001 From: Michael van Nes Date: Thu, 19 Nov 2020 12:24:52 +0100 Subject: [PATCH 1/3] Update minimum php version to 7.3 --- .travis.yml | 17 ++++++----------- composer.json | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed8a45f..dff6e54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,25 +10,20 @@ env: - COMPOSER_FLAGS="--prefer-stable" php: - - '7.1' - - '7.2' - - '7.3' + - 7.3 + - 7.4 - nightly matrix: include: - - php: 7.1 - env: COMPOSER_FLAGS="--prefer-lowest" - - php: 7.1 - env: COMPOSER_FLAGS="" - - php: 7.2 - env: COMPOSER_FLAGS="--prefer-lowest" - - php: 7.2 - env: COMPOSER_FLAGS="" - php: 7.3 env: COMPOSER_FLAGS="--prefer-lowest" - php: 7.3 env: COMPOSER_FLAGS="" + - php: 7.4 + env: COMPOSER_FLAGS="--prefer-lowest" + - php: 7.4 + env: COMPOSER_FLAGS="" allow_failures: - php: nightly diff --git a/composer.json b/composer.json index e2aeda3..4859549 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "abandoned": true, "require": { - "php": "^7.1.0", + "php": "^7.3", "ext-json": "*", "monolog/monolog": "~1.25", "symfony/monolog-bundle": "^4.0.0||^3.1.0", From 386a0ad62c23bf1a1185b045eb27ef97d83c4568 Mon Sep 17 00:00:00 2001 From: Michael van Nes Date: Thu, 19 Nov 2020 16:23:29 +0100 Subject: [PATCH 2/3] Fix travis by removing deprecations --- src/Bundle/Command/CompileCommand.php | 3 ++- src/Component/Asset/Compiler.php | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/Command/CompileCommand.php b/src/Bundle/Command/CompileCommand.php index fb4f983..f42463a 100644 --- a/src/Bundle/Command/CompileCommand.php +++ b/src/Bundle/Command/CompileCommand.php @@ -39,8 +39,9 @@ public function __construct(CacheGuard $guard) * * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->guard->rebuild(); + return 0; } } diff --git a/src/Component/Asset/Compiler.php b/src/Component/Asset/Compiler.php index c4ba2a7..1829fdd 100644 --- a/src/Component/Asset/Compiler.php +++ b/src/Component/Asset/Compiler.php @@ -97,7 +97,6 @@ public function compile(): string ); $this->profiler->set('compiler.performance.prepare', $this->stopwatch->stop('webpack.prepare')->getDuration()); $this->stopwatch->start('webpack.compiler'); - $this->process->inheritEnvironmentVariables(true); $this->process->run(); $output = $this->process->getOutput() . $this->process->getErrorOutput(); From fc041c4d0a2cf4271ae37e215e14a8ec919c52c9 Mon Sep 17 00:00:00 2001 From: Michael van Nes Date: Fri, 20 Nov 2020 08:41:59 +0100 Subject: [PATCH 3/3] Update phpunit to avoid failing on deprecations --- composer.json | 5 +-- phpunit.xml.dist | 35 ++++++++----------- .../DependencyInjection/Configuration.php | 21 ++--------- test/AbstractTestCase.php | 21 ++--------- .../WebpackCompileCacheWarmerTest.php | 3 ++ test/Bundle/Command/CompileCommandTest.php | 3 ++ .../DependencyInjection/ConfigurationTest.php | 3 ++ .../WebpackCompilerPassTest.php | 3 ++ .../WebpackExtensionTest.php | 3 ++ .../EventListener/RequestListenerTest.php | 3 ++ .../Twig/Token/WebpackTokenParserTest.php | 3 ++ test/Bundle/Twig/TwigExtensionTest.php | 5 ++- test/Bundle/WebpackBundleTest.php | 3 ++ test/Component/Asset/CacheGuardTest.php | 3 ++ test/Component/Asset/TemplateFinderTest.php | 3 ++ test/Component/Asset/TrackerTest.php | 7 ++-- test/Functional/TwigTest.php | 5 ++- 17 files changed, 61 insertions(+), 68 deletions(-) diff --git a/composer.json b/composer.json index 4859549..ff92342 100644 --- a/composer.json +++ b/composer.json @@ -14,8 +14,9 @@ }, "require-dev": { "hostnet/phpcs-tool": "^8.3", - "phpunit/phpunit": "^7.5.9", - "symfony/phpunit-bridge": "^3.3.2" + "phpunit/phpunit": "^9.4", + "symfony/phpunit-bridge": "^3.3.2", + "phpspec/prophecy-phpunit": "^2.0" }, "conflict": { "phpdocumentor/type-resolver": "<0.2.1" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e1d7bf3..ee9a4e8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,22 +1,17 @@ - - - - - - - - ./test - - - - - ./src - - + + + + ./src + + + + + + + + + ./test + + diff --git a/src/Bundle/DependencyInjection/Configuration.php b/src/Bundle/DependencyInjection/Configuration.php index 5f48805..f50129b 100644 --- a/src/Bundle/DependencyInjection/Configuration.php +++ b/src/Bundle/DependencyInjection/Configuration.php @@ -14,7 +14,6 @@ use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; -use Symfony\Component\HttpKernel\Kernel; class Configuration implements ConfigurationInterface { @@ -174,27 +173,11 @@ private function applyConfigurationFromClass($interface, NodeBuilder $node_build private function createTreeBuilder(): TreeBuilder { - if (Kernel::VERSION_ID >= 40200) { - return new TreeBuilder(self::CONFIG_ROOT); - } - - if (Kernel::VERSION_ID >= 30300 && Kernel::VERSION_ID < 40200) { - return new TreeBuilder(); - } - - throw new \RuntimeException('This bundle can only be used by Symfony 3.3 and up.'); + return new TreeBuilder(self::CONFIG_ROOT); } private function retrieveRootNode(TreeBuilder $tree_builder): NodeDefinition { - if (Kernel::VERSION_ID >= 40200) { - return $tree_builder->getRootNode(); - } - - if (Kernel::VERSION_ID >= 30300 && Kernel::VERSION_ID < 40200) { - return $tree_builder->root(self::CONFIG_ROOT); - } - - throw new \RuntimeException('This bundle can only be used by Symfony 3.3 and up.'); + return $tree_builder->getRootNode(); } } diff --git a/test/AbstractTestCase.php b/test/AbstractTestCase.php index 5fc0399..d45064d 100644 --- a/test/AbstractTestCase.php +++ b/test/AbstractTestCase.php @@ -9,33 +9,16 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\HttpKernel\Kernel; class AbstractTestCase extends TestCase { protected function createTreeBuilder(string $config_root): TreeBuilder { - if (Kernel::VERSION_ID >= 40200) { - return new TreeBuilder($config_root); - } - - if (Kernel::VERSION_ID >= 30300 && Kernel::VERSION_ID < 40200) { - return new TreeBuilder(); - } - - throw new \RuntimeException('This bundle can only be used by Symfony 3.3 and up.'); + return new TreeBuilder($config_root); } protected function retrieveRootNode(TreeBuilder $tree_builder, string $config_root): NodeDefinition { - if (Kernel::VERSION_ID >= 40200) { - return $tree_builder->getRootNode(); - } - - if (Kernel::VERSION_ID >= 30300 && Kernel::VERSION_ID < 40200) { - return $tree_builder->root($config_root); - } - - throw new \RuntimeException('This bundle can only be used by Symfony 3.3 and up.'); + return $tree_builder->getRootNode(); } } diff --git a/test/Bundle/CacheWarmer/WebpackCompileCacheWarmerTest.php b/test/Bundle/CacheWarmer/WebpackCompileCacheWarmerTest.php index 92ae871..04a3abd 100644 --- a/test/Bundle/CacheWarmer/WebpackCompileCacheWarmerTest.php +++ b/test/Bundle/CacheWarmer/WebpackCompileCacheWarmerTest.php @@ -8,12 +8,15 @@ use Hostnet\Component\Webpack\Asset\CacheGuard; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * @covers \Hostnet\Bundle\WebpackBundle\CacheWarmer\WebpackCompileCacheWarmer */ class WebpackCompileCacheWarmerTest extends TestCase { + use ProphecyTrait; + /** * Simple test to see the guard is executed from the cache warmer. */ diff --git a/test/Bundle/Command/CompileCommandTest.php b/test/Bundle/Command/CompileCommandTest.php index cab2427..de7b0f4 100644 --- a/test/Bundle/Command/CompileCommandTest.php +++ b/test/Bundle/Command/CompileCommandTest.php @@ -8,6 +8,7 @@ use Hostnet\Component\Webpack\Asset\CacheGuard; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\NullOutput; @@ -16,6 +17,8 @@ */ class CompileCommandTest extends TestCase { + use ProphecyTrait; + /** * Simple test to see the validate function is executed from the CacheGard class. */ diff --git a/test/Bundle/DependencyInjection/ConfigurationTest.php b/test/Bundle/DependencyInjection/ConfigurationTest.php index e0b88ab..94d8deb 100644 --- a/test/Bundle/DependencyInjection/ConfigurationTest.php +++ b/test/Bundle/DependencyInjection/ConfigurationTest.php @@ -9,12 +9,15 @@ use Hostnet\Component\Webpack\Configuration\Loader\CssLoader; use Hostnet\Component\Webpack\Configuration\Plugin\DefinePlugin; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * @covers \Hostnet\Bundle\WebpackBundle\DependencyInjection\Configuration */ class ConfigurationTest extends TestCase { + use ProphecyTrait; + public function testGetConfigTreeBuilder(): void { $config = new Configuration([], [DefinePlugin::class, CssLoader::class]); diff --git a/test/Bundle/DependencyInjection/WebpackCompilerPassTest.php b/test/Bundle/DependencyInjection/WebpackCompilerPassTest.php index d0ea40e..aab8bb8 100644 --- a/test/Bundle/DependencyInjection/WebpackCompilerPassTest.php +++ b/test/Bundle/DependencyInjection/WebpackCompilerPassTest.php @@ -15,6 +15,7 @@ use Hostnet\Fixture\WebpackBundle\Bundle\BarBundle\BarBundle; use Hostnet\Fixture\WebpackBundle\Bundle\FooBundle\FooBundle; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -29,6 +30,8 @@ */ class WebpackCompilerPassTest extends TestCase { + use ProphecyTrait; + public function testPass(): void { $bundle = new WebpackBundle(); diff --git a/test/Bundle/DependencyInjection/WebpackExtensionTest.php b/test/Bundle/DependencyInjection/WebpackExtensionTest.php index 6a5595c..8cf26d4 100644 --- a/test/Bundle/DependencyInjection/WebpackExtensionTest.php +++ b/test/Bundle/DependencyInjection/WebpackExtensionTest.php @@ -7,6 +7,7 @@ namespace Hostnet\Bundle\WebpackBundle\DependencyInjection; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; /** @@ -14,6 +15,8 @@ */ class WebpackExtensionTest extends TestCase { + use ProphecyTrait; + public function testAlias(): void { self::assertEquals(Configuration::CONFIG_ROOT, (new WebpackExtension())->getAlias()); diff --git a/test/Bundle/EventListener/RequestListenerTest.php b/test/Bundle/EventListener/RequestListenerTest.php index 956ee99..2733076 100644 --- a/test/Bundle/EventListener/RequestListenerTest.php +++ b/test/Bundle/EventListener/RequestListenerTest.php @@ -8,6 +8,7 @@ use Hostnet\Component\Webpack\Asset\CacheGuard; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\HttpKernel\Event\GetResponseEvent; /** @@ -15,6 +16,8 @@ */ class RequestListenerTest extends TestCase { + use ProphecyTrait; + public function testRequestNoMasterRequest(): void { $event = $this->prophesize(GetResponseEvent::class); diff --git a/test/Bundle/Twig/Token/WebpackTokenParserTest.php b/test/Bundle/Twig/Token/WebpackTokenParserTest.php index cb296f4..8e1e9c6 100644 --- a/test/Bundle/Twig/Token/WebpackTokenParserTest.php +++ b/test/Bundle/Twig/Token/WebpackTokenParserTest.php @@ -8,6 +8,7 @@ use Hostnet\Bundle\WebpackBundle\Twig\TwigExtension; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Twig\Loader\LoaderInterface; /** @@ -15,6 +16,8 @@ */ class WebpackTokenParserTest extends TestCase { + use ProphecyTrait; + public function testParser(): void { $loader = $this->prophesize(LoaderInterface::class)->reveal(); diff --git a/test/Bundle/Twig/TwigExtensionTest.php b/test/Bundle/Twig/TwigExtensionTest.php index fc95290..cf54e24 100644 --- a/test/Bundle/Twig/TwigExtensionTest.php +++ b/test/Bundle/Twig/TwigExtensionTest.php @@ -7,6 +7,7 @@ namespace Hostnet\Bundle\WebpackBundle\Twig; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Twig\Loader\LoaderInterface; /** @@ -14,6 +15,8 @@ */ class TwigExtensionTest extends TestCase { + use ProphecyTrait; + public function testExtension(): void { $loader = $this->prophesize(LoaderInterface::class)->reveal(); @@ -35,7 +38,7 @@ public function testAssets($expected, $asset, $web_dir, $dump_path, $public_path self::assertEquals($expected, $extension->webpackPublic($asset)); } - public function assetProvider() + public function assetProvider(): iterable { return [ ['/bundles/img.png', 'img.png', __DIR__ . '/web/', '/bundles/', '/'], diff --git a/test/Bundle/WebpackBundleTest.php b/test/Bundle/WebpackBundleTest.php index 901ae4e..61fe70d 100644 --- a/test/Bundle/WebpackBundleTest.php +++ b/test/Bundle/WebpackBundleTest.php @@ -8,6 +8,7 @@ use Hostnet\Bundle\WebpackBundle\DependencyInjection\WebpackCompilerPass; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; /** @@ -15,6 +16,8 @@ */ class WebpackBundleTest extends TestCase { + use ProphecyTrait; + public function testBuild(): void { $bundle = new WebpackBundle(); diff --git a/test/Component/Asset/CacheGuardTest.php b/test/Component/Asset/CacheGuardTest.php index 1d4cbcb..007bd1d 100644 --- a/test/Component/Asset/CacheGuardTest.php +++ b/test/Component/Asset/CacheGuardTest.php @@ -7,6 +7,7 @@ namespace Hostnet\Component\Webpack\Asset; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Log\LoggerInterface; /** @@ -14,6 +15,8 @@ */ class CacheGuardTest extends TestCase { + use ProphecyTrait; + /** * Simple test for the case the cache is outdated. */ diff --git a/test/Component/Asset/TemplateFinderTest.php b/test/Component/Asset/TemplateFinderTest.php index b7cb6a5..6dc2284 100644 --- a/test/Component/Asset/TemplateFinderTest.php +++ b/test/Component/Asset/TemplateFinderTest.php @@ -8,6 +8,7 @@ use Hostnet\Fixture\WebpackBundle\Bundle\BarBundle\BarBundle; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\HttpKernel\Kernel; /** @@ -15,6 +16,8 @@ */ class TemplateFinderTest extends TestCase { + use ProphecyTrait; + public function testFindAllTemplates(): void { $kernel = $this->prophesize(Kernel::class); diff --git a/test/Component/Asset/TrackerTest.php b/test/Component/Asset/TrackerTest.php index df44bd7..2682690 100644 --- a/test/Component/Asset/TrackerTest.php +++ b/test/Component/Asset/TrackerTest.php @@ -8,7 +8,7 @@ use Hostnet\Component\Webpack\Profiler\Profiler; use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Filesystem\Exception\FileNotFoundException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Templating\TemplateReferenceInterface; @@ -18,6 +18,8 @@ */ class TrackerTest extends TestCase { + use ProphecyTrait; + /** * The root directory of the application a.k.a. %kernel.root_dir% * @@ -39,9 +41,6 @@ class TrackerTest extends TestCase */ private $output_dir; - /** - * {@inheritDoc} - */ protected function setUp(): void { $fixture_path = realpath(__DIR__ . '/../../Fixture'); diff --git a/test/Functional/TwigTest.php b/test/Functional/TwigTest.php index 5c185f2..414d1b6 100644 --- a/test/Functional/TwigTest.php +++ b/test/Functional/TwigTest.php @@ -6,7 +6,6 @@ namespace Hostnet\Functional; -use Hostnet\Fixture\WebpackBundle\TestKernel; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\TwigBundle\TwigEngine; @@ -23,8 +22,8 @@ public function testTemplates(): void $twig = static::$kernel->getContainer()->get('twig'); $html = $twig->render('/common_id.html.twig'); - self::assertRegExp('~src="/compiled/shared\.js\?[0-9]+"~', $html); - self::assertRegExp('~href="/compiled/shared\.css\?[0-9]+"~', $html); + self::assertMatchesRegularExpression('~src="/compiled/shared\.js\?[0-9]+"~', $html); + self::assertMatchesRegularExpression('~href="/compiled/shared\.css\?[0-9]+"~', $html); $twig->render('/template.html.twig'); }