Skip to content

Commit

Permalink
Handle Prophesize Trait
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Jul 24, 2024
1 parent 64031e3 commit 411ca86
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Tests/Application/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
3 changes: 3 additions & 0 deletions Tests/Unit/Configuration/FormConfigurationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,6 +27,8 @@
*/
class FormConfigurationFactoryTest extends TestCase
{
use ProphecyTrait;

public function testBuildByDynamic(): void
{
$dynamic = $this->createDynamic();
Expand Down
3 changes: 3 additions & 0 deletions Tests/Unit/Event/ProtectedMediaSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +30,8 @@

class ProtectedMediaSubscriberTest extends TestCase
{
use ProphecyTrait;

/**
* @var EntityManagerInterface|ObjectProphecy
*/
Expand Down
3 changes: 3 additions & 0 deletions Tests/Unit/Event/SendinblueListSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +34,8 @@

class SendinblueListSubscriberTest extends TestCase
{
use ProphecyTrait;

/**
* @var RequestStack
*/
Expand Down
3 changes: 3 additions & 0 deletions Tests/Unit/Mail/MailerHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,8 @@
*/
class MailerHelperTest extends TestCase
{
use ProphecyTrait;

/**
* @var MailerHelper
*/
Expand Down
19 changes: 19 additions & 0 deletions Tests/prophecy-trait-bc-layer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/*
* This file is part of Sulu.
*
* (c) Sulu GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Prophecy\PhpUnit;

/**
* @internal
*/
trait ProphecyTrait
{
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"massive/search-bundle": "^2.0",
"php-cs-fixer/shim": "^3.0",
"phpspec/prophecy": "^1.14",
"phpspec/prophecy-phpunit": "^1.0 || ^2.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ parameters:
- %currentWorkingDirectory%/vendor/*
- %currentWorkingDirectory%/Tests/*
- %currentWorkingDirectory%/DependencyInjection/Configuration.php
- %currentWorkingDirectory%/Tests/prophecy-trait-bc-layer.php
symfony:
container_xml_path: %rootDir%/../../../Tests/Application/var/cache/admin/dev/Sulu_Bundle_FormBundle_Tests_Application_KernelDevDebugContainer.xml
console_application_loader: Tests/phpstan/console-application.php
Expand Down

0 comments on commit 411ca86

Please sign in to comment.