From eaa010f97abf34b7008268e95179ff1a72a48aea Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Tue, 4 Oct 2022 09:15:29 +0100 Subject: [PATCH] Issue #3254199 by longwave: Remove Prophecy PhpUnit compatibility check --- .../tests/src/Functional/ProviderRepositoryTest.php | 3 +++ core/tests/Drupal/KernelTests/KernelTestBase.php | 2 ++ .../PhpUnit9/TestCompatibilityTrait.php | 10 ---------- .../Plugin/Discovery/AnnotationBridgeDecoratorTest.php | 4 ++-- .../Component/DependencyInjection/ContainerTest.php | 4 ++-- .../Dumper/OptimizedPhpArrayDumperTest.php | 4 ++-- .../Tests/Component/Gettext/PoStreamWriterTest.php | 4 ++-- .../Tests/Component/Plugin/PluginManagerBaseTest.php | 4 ++-- .../VendorHardening/VendorHardeningPluginTest.php | 4 ++-- core/tests/Drupal/Tests/UnitTestCase.php | 2 ++ 10 files changed, 19 insertions(+), 22 deletions(-) diff --git a/core/modules/media/tests/src/Functional/ProviderRepositoryTest.php b/core/modules/media/tests/src/Functional/ProviderRepositoryTest.php index 2e81efc6b783..d791a2f90ea7 100644 --- a/core/modules/media/tests/src/Functional/ProviderRepositoryTest.php +++ b/core/modules/media/tests/src/Functional/ProviderRepositoryTest.php @@ -4,6 +4,7 @@ use Drupal\media\OEmbed\ProviderException; use GuzzleHttp\Psr7\Utils; +use Prophecy\PhpUnit\ProphecyTrait; /** * Tests the oEmbed provider repository. @@ -14,6 +15,8 @@ */ class ProviderRepositoryTest extends MediaFunctionalTestBase { + use ProphecyTrait; + /** * {@inheritdoc} */ diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index eab4a431aa08..47fd9b586284 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -26,6 +26,7 @@ use Drupal\TestTools\TestVarDumper; use PHPUnit\Framework\Exception; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpFoundation\Request; @@ -89,6 +90,7 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa use TestRequirementsTrait; use PhpUnitWarnings; use PhpUnitCompatibilityTrait; + use ProphecyTrait; use ExpectDeprecationTrait; /** diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php index 997f5e245f19..590fc337be2e 100644 --- a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php +++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php @@ -2,19 +2,9 @@ namespace Drupal\TestTools\PhpUnitCompatibility\PhpUnit9; -use Prophecy\PhpUnit\ProphecyTrait; - -// @todo Replace with a proper dependency when we stop supporting PHPUnit 8. -if (!trait_exists(ProphecyTrait::class)) { - print "Drupal requires Prophecy PhpUnit when using PHPUnit 9 or greater. Please use 'composer require --dev phpspec/prophecy-phpunit:^2' to ensure that it is present.\n"; - exit(1); -} - /** * Drupal's forward compatibility layer with multiple versions of PHPUnit. */ trait TestCompatibilityTrait { - use ProphecyTrait; - } diff --git a/core/tests/Drupal/Tests/Component/Annotation/Plugin/Discovery/AnnotationBridgeDecoratorTest.php b/core/tests/Drupal/Tests/Component/Annotation/Plugin/Discovery/AnnotationBridgeDecoratorTest.php index 324eab95b4bd..848f499ee106 100644 --- a/core/tests/Drupal/Tests/Component/Annotation/Plugin/Discovery/AnnotationBridgeDecoratorTest.php +++ b/core/tests/Drupal/Tests/Component/Annotation/Plugin/Discovery/AnnotationBridgeDecoratorTest.php @@ -6,8 +6,8 @@ use Drupal\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecorator; use Drupal\Component\Plugin\Definition\PluginDefinition; use Drupal\Component\Plugin\Discovery\DiscoveryInterface; -use Drupal\Tests\PhpUnitCompatibilityTrait; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * @coversDefaultClass \Drupal\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecorator @@ -15,7 +15,7 @@ */ class AnnotationBridgeDecoratorTest extends TestCase { - use PhpUnitCompatibilityTrait; + use ProphecyTrait; /** * @covers ::getDefinitions diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php index 1a2e3115d6dd..a4990cc36c3f 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php @@ -8,8 +8,8 @@ namespace Drupal\Tests\Component\DependencyInjection; use Drupal\Component\Utility\Crypt; -use Drupal\Tests\PhpUnitCompatibilityTrait; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; @@ -25,7 +25,7 @@ */ class ContainerTest extends TestCase { - use PhpUnitCompatibilityTrait; + use ProphecyTrait; /** * The tested container. diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php index e53b27b6cb83..4fc0ec6a3b00 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php @@ -8,8 +8,8 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper { use Drupal\Component\Utility\Crypt; - use Drupal\Tests\PhpUnitCompatibilityTrait; use PHPUnit\Framework\TestCase; + use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; @@ -26,8 +26,8 @@ */ class OptimizedPhpArrayDumperTest extends TestCase { - use PhpUnitCompatibilityTrait; use ExpectDeprecationTrait; + use ProphecyTrait; /** * The container builder instance. diff --git a/core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php b/core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php index 361284d3d995..c3994a67cbc4 100644 --- a/core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php +++ b/core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php @@ -5,10 +5,10 @@ use Drupal\Component\Gettext\PoHeader; use Drupal\Component\Gettext\PoItem; use Drupal\Component\Gettext\PoStreamWriter; -use Drupal\Tests\PhpUnitCompatibilityTrait; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamFile; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * @coversDefaultClass \Drupal\Component\Gettext\PoStreamWriter @@ -16,7 +16,7 @@ */ class PoStreamWriterTest extends TestCase { - use PhpUnitCompatibilityTrait; + use ProphecyTrait; /** * The PO writer object under test. diff --git a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php index 38d47ea3456a..36b60b68a553 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php @@ -5,8 +5,8 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Plugin\Mapper\MapperInterface; use Drupal\Component\Plugin\PluginManagerBase; -use Drupal\Tests\PhpUnitCompatibilityTrait; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * @coversDefaultClass \Drupal\Component\Plugin\PluginManagerBase @@ -14,7 +14,7 @@ */ class PluginManagerBaseTest extends TestCase { - use PhpUnitCompatibilityTrait; + use ProphecyTrait; /** * A callback method for mocking FactoryInterface objects. diff --git a/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php b/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php index 5b43d9a0344e..81b286b986de 100644 --- a/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php +++ b/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php @@ -8,10 +8,10 @@ use Composer\Package\RootPackageInterface; use Drupal\Composer\Plugin\VendorHardening\Config; use Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin; -use Drupal\Tests\PhpUnitCompatibilityTrait; use Drupal\Tests\Traits\PhpUnitWarnings; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * @coversDefaultClass \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin @@ -20,7 +20,7 @@ class VendorHardeningPluginTest extends TestCase { use PhpUnitWarnings; - use PhpUnitCompatibilityTrait; + use ProphecyTrait; /** * {@inheritdoc} diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index 0b40c075f8e8..44f46e6bb825 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -12,6 +12,7 @@ use Drupal\Tests\Traits\PhpUnitWarnings; use Drupal\TestTools\TestVarDumper; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\VarDumper\VarDumper; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -27,6 +28,7 @@ abstract class UnitTestCase extends TestCase { use PhpUnitWarnings; use PhpUnitCompatibilityTrait; + use ProphecyTrait; use ExpectDeprecationTrait; /** -- GitLab