Skip to content

Commit

Permalink
remove phpunit bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Jul 2, 2024
1 parent 4a358d0 commit f032a07
Show file tree
Hide file tree
Showing 26 changed files with 26 additions and 90 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
"symfony/maker-bundle": "^1.24",
"symfony/mercure-bundle": "*",
"symfony/messenger": "^6.4 || ^7.0",
"symfony/phpunit-bridge": "^6.4.1 || ^7.0",
"symfony/routing": "^6.4 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/security-core": "^6.4 || ^7.0",
Expand Down
8 changes: 6 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" backupGlobals="false" bootstrap="tests/Fixtures/app/bootstrap.php" colors="true" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
bootstrap="tests/Fixtures/app/bootstrap.php"
colors="true"
cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="-1"/>
Expand All @@ -24,7 +28,7 @@
</exclude>
</groups>

<source ignoreIndirectDeprecations="true">
<source ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="true">
<include>
<directory>.</directory>
</include>
Expand Down
2 changes: 0 additions & 2 deletions src/Doctrine/Odm/Tests/State/CollectionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @group mongodb
*/
class CollectionProviderTest extends TestCase
{
use ExpectDeprecationTrait;
use ProphecyTrait;

private ObjectProphecy $managerRegistryProphecy;
Expand Down
2 changes: 0 additions & 2 deletions src/Doctrine/Odm/Tests/State/ItemProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
use Doctrine\Persistence\ObjectRepository;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @group mongodb
*/
class ItemProviderTest extends TestCase
{
use ExpectDeprecationTrait;
use ProphecyTrait;

public function testGetItemSingleIdentifier(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
use Elasticsearch\Namespaces\CatNamespace;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

class ElasticsearchProviderResourceMetadataCollectionFactoryTest extends TestCase
{
use ExpectDeprecationTrait;
use ProphecyTrait;

public function testConstruct(): void
Expand Down
1 change: 0 additions & 1 deletion src/GraphQl/Subscription/SubscriptionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace ApiPlatform\GraphQl\Subscription;

use ApiPlatform\GraphQl\Resolver\Stage\SerializeStageInterface;
use ApiPlatform\GraphQl\Resolver\Util\IdentifierTrait;
use ApiPlatform\Metadata\GraphQl\Operation;
use ApiPlatform\Metadata\GraphQl\Subscription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @author Antoine Bluchet <soyuka@gmail.com>
*/
class UriTemplateResourceMetadataCollectionFactoryTest extends TestCase
{
use ExpectDeprecationTrait;
use ProphecyTrait;

public function testCreate(): void
Expand Down
3 changes: 0 additions & 3 deletions src/Metadata/Tests/Util/IriHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
use ApiPlatform\Metadata\UrlGeneratorInterface;
use ApiPlatform\Metadata\Util\IriHelper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
class IriHelperTest extends TestCase
{
use ExpectDeprecationTrait;

public function testHelpers(): void
{
$parsed = [
Expand Down
2 changes: 0 additions & 2 deletions src/OpenApi/Tests/Factory/OpenApiFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Container\ContainerInterface;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;

class OpenApiFactoryTest extends TestCase
{
use ExpectDeprecationTrait;
use ProphecyTrait;

private const OPERATION_FORMATS = [
Expand Down
2 changes: 0 additions & 2 deletions src/Serializer/Tests/AbstractItemNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\PropertyInfo\Type;
Expand All @@ -59,7 +58,6 @@
*/
class AbstractItemNormalizerTest extends TestCase
{
use ExpectDeprecationTrait;
use ProphecyTrait;

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Serializer/Tests/ItemNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
Expand All @@ -43,7 +42,6 @@
*/
class ItemNormalizerTest extends TestCase
{
use ExpectDeprecationTrait;
use ProphecyTrait;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Bundle/Resources/config/graphql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,9 @@
<service id="api_platform.graphql.subscription.subscription_manager" class="ApiPlatform\GraphQl\Subscription\SubscriptionManager">
<argument type="service" id="api_platform.graphql.cache.subscription" />
<argument type="service" id="api_platform.graphql.subscription.subscription_identifier_generator" />
<argument type="service" id="api_platform.graphql.resolver.stage.serialize" on-invalid="ignore" />
<argument type="service" id="api_platform.graphql.state_processor.normalize" on-invalid="ignore" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="api_platform.graphql.state_processor.normalize" on-invalid="ignore" />
</service>

<!-- Serializer -->
Expand Down
7 changes: 0 additions & 7 deletions src/Symfony/Bundle/Test/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace ApiPlatform\Symfony\Bundle\Test;

use ApiPlatform\Metadata\IriConverterInterface;
use PHPUnit\Framework\Attributes\BeforeClass;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
Expand All @@ -29,12 +28,6 @@ abstract class ApiTestCase extends KernelTestCase
{
use ApiTestAssertionsTrait;

#[BeforeClass]
public static function before(): void
{
static::bootKernel();
}

/**
* {@inheritdoc}
*/
Expand Down
19 changes: 14 additions & 5 deletions tests/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Symfony\Component\ErrorHandler\ErrorRenderer\ErrorRendererInterface;
use Symfony\Component\HttpClient\Messenger\PingWebhookMessageHandler;
use Symfony\Component\HttpFoundation\Session\SessionFactory;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
use Symfony\Component\Security\Core\Authorization\Strategy\AccessDecisionStrategyInterface;
Expand Down Expand Up @@ -68,6 +69,13 @@ public function registerBundles(): array
new WebProfilerBundle(),
new FrameworkBundle(),
new MakerBundle(),
new class extends Bundle
{
public function shutdown(): void
{
restore_exception_handler();
}
}
];

if (null === ($_ENV['APP_PHPUNIT'] ?? null)) {
Expand All @@ -90,14 +98,14 @@ public function getProjectDir(): string

protected function configureRoutes($routes): void
{
$routes->import(__DIR__."/config/routing_{$this->getEnvironment()}.yml");
$routes->import(__DIR__ . "/config/routing_{$this->getEnvironment()}.yml");
}

protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader): void
{
$c->setParameter('kernel.project_dir', __DIR__);

$loader->load(__DIR__."/config/config_{$this->getEnvironment()}.yml");
$loader->load(__DIR__ . "/config/config_{$this->getEnvironment()}.yml");

$c->getDefinition(DoctrineContext::class)->setArgument('$passwordHasher', class_exists(NativePasswordHasher::class) ? 'security.user_password_encoder' : 'security.user_password_hasher');

Expand Down Expand Up @@ -260,7 +268,7 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [
]);

// TODO: remove this check and move this config in config_common.yml when dropping support for DoctrineBundle <2.10
if (defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) {
if (defined(ConnectionFactory::class . '::DEFAULT_SCHEME_MAP')) {
$c->prependExtensionConfig('doctrine', [
'orm' => [
'report_fields_where_declared' => true,
Expand All @@ -270,7 +278,7 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [
]);
}

$loader->load(__DIR__.'/config/config_swagger.php');
$loader->load(__DIR__ . '/config/config_swagger.php');

if ('mongodb' === $this->environment) {
$c->prependExtensionConfig('api_platform', [
Expand All @@ -291,7 +299,8 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [

protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new class() implements CompilerPassInterface {
$container->addCompilerPass(new class() implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if ($container->hasDefinition(TailCursorDoctrineODMCommand::class)) { // @phpstan-ignore-line
Expand Down
10 changes: 0 additions & 10 deletions tests/Fixtures/app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,12 @@

date_default_timezone_set('UTC');

// PHPUnit's autoloader
if (!file_exists($phpUnitAutoloaderPath = __DIR__.'/../../../vendor/bin/.phpunit/phpunit/vendor/autoload.php')) {
exit('PHPUnit is not installed. Please run ./vendor/bin/simple-phpunit to install it');
}

// Increase default max nesting level allowed by XDebug for the Symfony container
$xdebugMaxNestingLevel = ini_get('xdebug.max_nesting_level');
if (false !== $xdebugMaxNestingLevel && $xdebugMaxNestingLevel <= 512) {
ini_set('xdebug.max_nesting_level', 512);
}

$phpunitLoader = require $phpUnitAutoloaderPath;
// Don't register the PHPUnit autoloader before the normal autoloader to prevent weird issues
$phpunitLoader->unregister();
$phpunitLoader->register();

$loader = require __DIR__.'/../../../vendor/autoload.php';
require __DIR__.'/AppKernel.php';

Expand Down
2 changes: 1 addition & 1 deletion tests/JsonSchema/Command/JsonSchemaGenerateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

use ApiPlatform\Tests\Fixtures\TestBundle\Document\Dummy as DocumentDummy;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy;
use ApiPlatform\Tests\KernelTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\ApplicationTester;

/**
Expand Down
26 changes: 0 additions & 26 deletions tests/KernelTestCase.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/OpenApi/Command/OpenApiCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace ApiPlatform\Tests\OpenApi\Command;

use ApiPlatform\OpenApi\OpenApi;
use ApiPlatform\Tests\KernelTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\ApplicationTester;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
use ApiPlatform\Symfony\Bundle\ArgumentResolver\PayloadArgumentResolver;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\ResourceImplementation;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\ResourceInterface;
use ApiPlatform\Tests\KernelTestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\GraphQlResolverPass;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand All @@ -25,8 +24,6 @@
*/
class GraphQlResolverPassTest extends TestCase
{
use ExpectDeprecationTrait;

public function testProcess(): void
{
$filterPass = new GraphQlResolverPass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use ApiPlatform\Symfony\Bundle\DependencyInjection\Configuration;
use Doctrine\ORM\OptimisticLockException;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
Expand All @@ -32,8 +31,6 @@
*/
class ConfigurationTest extends TestCase
{
use ExpectDeprecationTrait;

private Configuration $configuration;

private Processor $processor;
Expand Down
3 changes: 0 additions & 3 deletions tests/Symfony/Bundle/Test/ApiTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Tools\SchemaTool;
use PHPUnit\Framework\ExpectationFailedException;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

class ApiTestCaseTest extends ApiTestCase
{
use ExpectDeprecationTrait;

public static function providerFormats(): iterable
{
yield 'jsonapi' => ['jsonapi', 'application/vnd.api+json'];
Expand Down
2 changes: 0 additions & 2 deletions tests/Symfony/Bundle/Twig/ApiPlatformProfilerPanelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

/**
* @author Anthony GRASSIOT <antograssiot@free.fr>
*/
class ApiPlatformProfilerPanelTest extends WebTestCase
{
use ExpectDeprecationTrait;
private EntityManagerInterface $manager;
private SchemaTool $schemaTool;
private string $env;
Expand Down
Loading

0 comments on commit f032a07

Please sign in to comment.