From 411ca86c55ccba07a572561f6a91ed81b4ba4da9 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 24 Jul 2024 18:39:55 +0200 Subject: [PATCH] Handle Prophesize Trait --- Tests/Application/config/bootstrap.php | 4 ++++ .../FormConfigurationFactoryTest.php | 3 +++ .../Event/ProtectedMediaSubscriberTest.php | 3 +++ .../Event/SendinblueListSubscriberTest.php | 3 +++ Tests/Unit/Mail/MailerHelperTest.php | 3 +++ Tests/prophecy-trait-bc-layer.php | 19 +++++++++++++++++++ composer.json | 1 + phpstan.neon | 1 + 8 files changed, 37 insertions(+) create mode 100644 Tests/prophecy-trait-bc-layer.php diff --git a/Tests/Application/config/bootstrap.php b/Tests/Application/config/bootstrap.php index 7314acf9..30707549 100644 --- a/Tests/Application/config/bootstrap.php +++ b/Tests/Application/config/bootstrap.php @@ -21,6 +21,10 @@ require $file; +if (!\trait_exists(Prophecy\PhpUnit\ProphecyTrait::class)) { // backwards compatibility layer for < PHP 7.3 + require __DIR__ . '/../../prophecy-trait-bc-layer.php'; +} + // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) if (\is_array($env = @include \dirname(__DIR__) . '/.env.local.php')) { diff --git a/Tests/Unit/Configuration/FormConfigurationFactoryTest.php b/Tests/Unit/Configuration/FormConfigurationFactoryTest.php index ce791041..a1d62196 100644 --- a/Tests/Unit/Configuration/FormConfigurationFactoryTest.php +++ b/Tests/Unit/Configuration/FormConfigurationFactoryTest.php @@ -12,6 +12,7 @@ namespace Sulu\Bundle\FormBundle\Tests\Unit\Configuration; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\FormBundle\Configuration\FormConfigurationFactory; use Sulu\Bundle\FormBundle\Configuration\MailConfigurationInterface; use Sulu\Bundle\FormBundle\Entity\Dynamic; @@ -26,6 +27,8 @@ */ class FormConfigurationFactoryTest extends TestCase { + use ProphecyTrait; + public function testBuildByDynamic(): void { $dynamic = $this->createDynamic(); diff --git a/Tests/Unit/Event/ProtectedMediaSubscriberTest.php b/Tests/Unit/Event/ProtectedMediaSubscriberTest.php index ca65f7ae..eb8ac205 100644 --- a/Tests/Unit/Event/ProtectedMediaSubscriberTest.php +++ b/Tests/Unit/Event/ProtectedMediaSubscriberTest.php @@ -15,6 +15,7 @@ use Doctrine\ORM\QueryBuilder; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\FormBundle\Event\ProtectedMediaSubscriber; use Sulu\Bundle\FormBundle\Tests\Application\Kernel; @@ -29,6 +30,8 @@ class ProtectedMediaSubscriberTest extends TestCase { + use ProphecyTrait; + /** * @var EntityManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Event/SendinblueListSubscriberTest.php b/Tests/Unit/Event/SendinblueListSubscriberTest.php index 55aff833..77dfebd6 100644 --- a/Tests/Unit/Event/SendinblueListSubscriberTest.php +++ b/Tests/Unit/Event/SendinblueListSubscriberTest.php @@ -15,6 +15,7 @@ use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Psr\Http\Message\RequestInterface; use Sulu\Bundle\FormBundle\Configuration\FormConfiguration; @@ -33,6 +34,8 @@ class SendinblueListSubscriberTest extends TestCase { + use ProphecyTrait; + /** * @var RequestStack */ diff --git a/Tests/Unit/Mail/MailerHelperTest.php b/Tests/Unit/Mail/MailerHelperTest.php index ae730026..54962a03 100644 --- a/Tests/Unit/Mail/MailerHelperTest.php +++ b/Tests/Unit/Mail/MailerHelperTest.php @@ -12,6 +12,7 @@ namespace Sulu\Bundle\FormBundle\Tests\Unit\Mail; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Psr\Log\LoggerInterface; use Sulu\Bundle\FormBundle\Mail\MailerHelper; @@ -27,6 +28,8 @@ */ class MailerHelperTest extends TestCase { + use ProphecyTrait; + /** * @var MailerHelper */ diff --git a/Tests/prophecy-trait-bc-layer.php b/Tests/prophecy-trait-bc-layer.php new file mode 100644 index 00000000..55757afb --- /dev/null +++ b/Tests/prophecy-trait-bc-layer.php @@ -0,0 +1,19 @@ +