diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 495ea2bc77c..8abb9e37d30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring ini-values: memory_limit=-1 tools: pecl, composer coverage: none @@ -89,7 +89,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring ini-values: memory_limit=-1 tools: composer coverage: none @@ -149,6 +149,7 @@ jobs: composer global require soyuka/pmu composer global config allow-plugins.soyuka/pmu true --no-interaction composer global link . + composer require --dev doctrine/mongodb-odm-bundle - name: Cache PHPStan results uses: actions/cache@v4 with: @@ -200,7 +201,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite coverage: pcov ini-values: memory_limit=-1 - name: Get composer cache directory @@ -217,6 +218,9 @@ jobs: composer global require soyuka/pmu composer global config allow-plugins.soyuka/pmu true --no-interaction composer global link . + - name: Force PHPUnit 11.5 for PHP 8.2 + if: matrix.php == '8.2' + run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies - name: Clear test app cache run: tests/Fixtures/app/console cache:clear --ansi - name: Run PHPUnit tests @@ -288,12 +292,17 @@ jobs: with: php-version: ${{ matrix.php.version }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite ini-values: memory_limit=-1 - name: PMU run: | composer global require soyuka/pmu composer global config allow-plugins.soyuka/pmu true --no-interaction + - name: Force PHPUnit 11.5 for PHP 8.2 + if: matrix.php.version == '8.2' + run: | + cd $(composer ${{matrix.component}} --cwd) + composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies - name: Linking if: ${{ !matrix.php.lowest && !matrix.php.minimal-changes }} run: | @@ -368,7 +377,7 @@ jobs: with: php-version: ${{ matrix.php.version }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite ini-values: memory_limit=-1 - name: Linking run: | @@ -408,7 +417,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite coverage: pcov ini-values: memory_limit=-1 - name: Get composer cache directory @@ -425,6 +434,9 @@ jobs: composer global require soyuka/pmu composer global config allow-plugins.soyuka/pmu true --no-interaction composer global link . + - name: Force PHPUnit 11.5 for PHP 8.2 + if: matrix.php == '8.2' + run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies - name: Clear test app cache run: tests/Fixtures/app/console cache:clear --ansi - name: Run Behat tests (PHP ${{ matrix.php }}) @@ -492,7 +504,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_pgsql, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_pgsql coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -543,7 +555,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_mysql, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_mysql coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -825,7 +837,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -878,7 +890,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -918,7 +930,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -957,7 +969,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -1000,7 +1012,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring coverage: none ini-values: memory_limit=-1 - name: Install additional packages @@ -1048,7 +1060,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -1098,7 +1110,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring coverage: none ini-values: memory_limit=-1 - name: Get composer cache directory @@ -1142,7 +1154,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, mongodb + extensions: intl, bcmath, curl, openssl, mbstring coverage: none ini-values: memory_limit=-1 - name: Install additional packages @@ -1314,7 +1326,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite ini-values: memory_limit=-1 - name: Setup node uses: actions/setup-node@v4 @@ -1369,7 +1381,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite ini-values: memory_limit=-1 - name: Update project dependencies run: | @@ -1377,6 +1389,10 @@ jobs: composer global config allow-plugins.soyuka/pmu true --no-interaction composer global link . --permanent composer api-platform/laravel update + - name: Force PHPUnit 11.5 for PHP 8.2 + if: matrix.php == '8.2' + working-directory: 'src/Laravel' + run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies - name: PHP version tweaks run: | composer run-script build @@ -1395,7 +1411,7 @@ jobs: with: php-version: 8.4 tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb + extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite ini-values: memory_limit=-1 - name: Update project dependencies run: | diff --git a/composer.json b/composer.json index a0f3bbc9e45..1df67d8036d 100644 --- a/composer.json +++ b/composer.json @@ -123,15 +123,11 @@ "willdurand/negotiation": "^3.1" }, "require-dev": { - "ext-mongodb": "^1.21 || ^2.0", "behat/behat": "^3.11", "behat/mink": "^1.9", - "doctrine/cache": "^1.11 || ^2.1", "doctrine/common": "^3.2.2", "doctrine/dbal": "^4.0", "doctrine/doctrine-bundle": "^2.11 || ^3.1", - "doctrine/mongodb-odm": "^2.10", - "doctrine/mongodb-odm-bundle": "^5.0", "doctrine/orm": "^2.17 || ^3.0", "elasticsearch/elasticsearch": "^7.17 || ^8.4 || ^9.0", "friends-of-behat/mink-browserkit-driver": "^1.3.1", @@ -156,7 +152,7 @@ "phpstan/phpstan-doctrine": "^2.0", "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-symfony": "^2.0", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "psr/log": "^1.0 || ^2.0 || ^3.0", "ramsey/uuid": "^4.7", "ramsey/uuid-doctrine": "^2.0", @@ -216,8 +212,5 @@ "symfony/json-streamer": "To use the JSON Streamer component.", "webonyx/graphql-php": "To support GraphQL." }, - "type": "library", - "repositories": [ - {"type": "vcs", "url": "https://github.com/soyuka/phpunit"} - ] + "type": "library" } diff --git a/src/Doctrine/Common/composer.json b/src/Doctrine/Common/composer.json index b99b133d299..4255d2ff8c0 100644 --- a/src/Doctrine/Common/composer.json +++ b/src/Doctrine/Common/composer.json @@ -34,7 +34,7 @@ "doctrine/mongodb-odm": "^2.10", "doctrine/orm": "^2.17 || ^3.0", "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/type-info": "^7.3 || ^8.0" }, "conflict": { @@ -76,11 +76,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Doctrine/Odm/Filter/DateFilter.php b/src/Doctrine/Odm/Filter/DateFilter.php index 227888c80f2..7bc5451d172 100644 --- a/src/Doctrine/Odm/Filter/DateFilter.php +++ b/src/Doctrine/Odm/Filter/DateFilter.php @@ -23,7 +23,6 @@ use ApiPlatform\Metadata\QueryParameter; use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter; use Doctrine\ODM\MongoDB\Aggregation\Builder; -use Doctrine\ODM\MongoDB\Types\Type as MongoDbType; /** * The date filter allows to filter a collection by date intervals. @@ -127,8 +126,8 @@ final class DateFilter extends AbstractFilter implements DateFilterInterface, Js use DateFilterTrait; public const DOCTRINE_DATE_TYPES = [ - MongoDbType::DATE => true, - MongoDbType::DATE_IMMUTABLE => true, + 'date' => true, + 'date_immutable' => true, ]; /** diff --git a/src/Doctrine/Odm/PropertyHelperTrait.php b/src/Doctrine/Odm/PropertyHelperTrait.php index 168e0cec6bc..c94220a7483 100644 --- a/src/Doctrine/Odm/PropertyHelperTrait.php +++ b/src/Doctrine/Odm/PropertyHelperTrait.php @@ -47,11 +47,11 @@ protected function getClassMetadata(string $resourceClass): ClassMetadata $managerRegistry = $this->getManagerRegistry(); $manager = $managerRegistry?->getManagerForClass($resourceClass); - if ($manager) { - return $manager->getClassMetadata($resourceClass); + if (!$manager) { + throw new InvalidArgumentException(\sprintf('Unable to get class metadata for resource "%s". No object manager found.', $resourceClass)); } - return new MongoDbOdmClassMetadata($resourceClass); + return $manager->getClassMetadata($resourceClass); } /** diff --git a/src/Doctrine/Odm/composer.json b/src/Doctrine/Odm/composer.json index 547dfc8f4e3..cbca401032d 100644 --- a/src/Doctrine/Odm/composer.json +++ b/src/Doctrine/Odm/composer.json @@ -36,7 +36,7 @@ "doctrine/doctrine-bundle": "^2.11 || ^3.1", "doctrine/mongodb-odm-bundle": "^5.0", "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/cache": "^6.4 || ^7.0 || ^8.0", "symfony/framework-bundle": "^6.4 || ^7.0 || ^8.0", "symfony/property-access": "^6.4 || ^7.0 || ^8.0", @@ -76,11 +76,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Doctrine/Orm/Filter/ExistsFilter.php b/src/Doctrine/Orm/Filter/ExistsFilter.php index 7dbb046630e..5315473587e 100644 --- a/src/Doctrine/Orm/Filter/ExistsFilter.php +++ b/src/Doctrine/Orm/Filter/ExistsFilter.php @@ -135,8 +135,9 @@ public function __construct(?ManagerRegistry $managerRegistry = null, ?LoggerInt public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void { $parameter = $context['parameter'] ?? null; + $propertyKey = $parameter?->getProperty(); - if (null !== ($value = $context['filters'][$parameter?->getProperty()] ?? null)) { + if (null !== $propertyKey && null !== ($value = $context['filters'][$propertyKey] ?? null)) { $this->filterProperty($this->denormalizePropertyName($parameter->getProperty()), $value, $queryBuilder, $queryNameGenerator, $resourceClass, $operation, $context); return; diff --git a/src/Doctrine/Orm/composer.json b/src/Doctrine/Orm/composer.json index 8952b55530c..0fb956e21f9 100644 --- a/src/Doctrine/Orm/composer.json +++ b/src/Doctrine/Orm/composer.json @@ -32,7 +32,7 @@ "require-dev": { "doctrine/doctrine-bundle": "^2.11 || ^3.1", "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "ramsey/uuid": "^4.7", "ramsey/uuid-doctrine": "^2.0", "symfony/cache": "^6.4 || ^7.0 || ^8.0", @@ -76,11 +76,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Documentation/composer.json b/src/Documentation/composer.json index 01bbdc9743c..ffc9291d303 100644 --- a/src/Documentation/composer.json +++ b/src/Documentation/composer.json @@ -39,12 +39,6 @@ } }, "require-dev": { - "phpunit/phpunit": "11.5.x-dev" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + "phpunit/phpunit": "^12.2" + } } diff --git a/src/Elasticsearch/composer.json b/src/Elasticsearch/composer.json index b23b4dfe7fc..9cb069e9bb4 100644 --- a/src/Elasticsearch/composer.json +++ b/src/Elasticsearch/composer.json @@ -38,7 +38,7 @@ }, "require-dev": { "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev" + "phpunit/phpunit": "^12.2" }, "autoload": { "psr-4": { @@ -76,11 +76,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/GraphQl/composer.json b/src/GraphQl/composer.json index 5f9c3c0d6fc..d7434df70f4 100644 --- a/src/GraphQl/composer.json +++ b/src/GraphQl/composer.json @@ -36,7 +36,7 @@ "twig/twig": "^1.42.3 || ^2.12 || ^3.0", "symfony/mercure-bundle": "*", "symfony/routing": "^6.4 || ^7.0 || ^8.0", - "phpunit/phpunit": "11.5.x-dev" + "phpunit/phpunit": "^12.2" }, "autoload": { "psr-4": { @@ -83,11 +83,5 @@ "conflict": { "symfony/http-client": "<6.4", "doctrine/inflector": "<2.0" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Hal/composer.json b/src/Hal/composer.json index 9f0c12a526d..2a86e130062 100644 --- a/src/Hal/composer.json +++ b/src/Hal/composer.json @@ -65,13 +65,7 @@ "test": "./vendor/bin/phpunit" }, "require-dev": { - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "api-platform/json-schema": "^4.1.11" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/HttpCache/composer.json b/src/HttpCache/composer.json index 9ab73411415..7f8ba1096be 100644 --- a/src/HttpCache/composer.json +++ b/src/HttpCache/composer.json @@ -33,7 +33,7 @@ "phpspec/prophecy-phpunit": "^2.2", "symfony/http-client": "^6.4 || ^7.0 || ^8.0", "symfony/type-info": "^7.3 || ^8.0", - "phpunit/phpunit": "11.5.x-dev" + "phpunit/phpunit": "^12.2" }, "autoload": { "psr-4": { @@ -70,11 +70,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Hydra/composer.json b/src/Hydra/composer.json index 0e2614722c2..c149384e84c 100644 --- a/src/Hydra/composer.json +++ b/src/Hydra/composer.json @@ -40,7 +40,7 @@ "api-platform/doctrine-common": "^4.2", "phpspec/prophecy": "^1.19", "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev" + "phpunit/phpunit": "^12.2" }, "autoload": { "psr-4": { @@ -77,11 +77,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/JsonApi/composer.json b/src/JsonApi/composer.json index 1e4190928c3..c1fa5481aba 100644 --- a/src/JsonApi/composer.json +++ b/src/JsonApi/composer.json @@ -34,7 +34,7 @@ "require-dev": { "phpspec/prophecy": "^1.19", "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/type-info": "^7.3 || ^8.0" }, "autoload": { @@ -72,11 +72,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/JsonLd/composer.json b/src/JsonLd/composer.json index a943fc85f06..114a9a1ca3f 100644 --- a/src/JsonLd/composer.json +++ b/src/JsonLd/composer.json @@ -69,12 +69,6 @@ }, "require-dev": { "symfony/type-info": "^7.3 || ^8.0", - "phpunit/phpunit": "11.5.x-dev" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + "phpunit/phpunit": "^12.2" + } } diff --git a/src/JsonSchema/composer.json b/src/JsonSchema/composer.json index 3e629bd3295..4ac6fa87cbc 100644 --- a/src/JsonSchema/composer.json +++ b/src/JsonSchema/composer.json @@ -34,7 +34,7 @@ }, "require-dev": { "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev" + "phpunit/phpunit": "^12.2" }, "autoload": { "psr-4": { @@ -71,11 +71,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Laravel/composer.json b/src/Laravel/composer.json index 5182488443b..92d1c1d880c 100644 --- a/src/Laravel/composer.json +++ b/src/Laravel/composer.json @@ -61,7 +61,7 @@ "orchestra/testbench": "^10.1", "phpdocumentor/type-resolver": "^1.7", "phpstan/phpdoc-parser": "^1.29 || ^2.0", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/http-client": "^7.4 || ^8.0" }, "autoload": { @@ -127,11 +127,5 @@ "lint": [ "@php vendor/bin/phpstan analyse --verbose --ansi" ] - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Metadata/composer.json b/src/Metadata/composer.json index 1b723268789..d0554035413 100644 --- a/src/Metadata/composer.json +++ b/src/Metadata/composer.json @@ -41,7 +41,7 @@ "api-platform/state": "^4.2.4", "phpspec/prophecy-phpunit": "^2.2", "phpstan/phpdoc-parser": "^1.29 || ^2.0", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/config": "^6.4 || ^7.0 || ^8.0", "symfony/routing": "^6.4 || ^7.0 || ^8.0", "symfony/var-dumper": "^6.4 || ^7.0 || ^8.0", @@ -88,11 +88,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/OpenApi/composer.json b/src/OpenApi/composer.json index ac0b0ca8213..00153da6c4b 100644 --- a/src/OpenApi/composer.json +++ b/src/OpenApi/composer.json @@ -39,7 +39,7 @@ }, "require-dev": { "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "api-platform/doctrine-common": "^4.2", "api-platform/doctrine-orm": "^4.2", "api-platform/doctrine-odm": "^4.2", @@ -80,11 +80,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/RamseyUuid/composer.json b/src/RamseyUuid/composer.json index 141300f2d33..02df35226f8 100644 --- a/src/RamseyUuid/composer.json +++ b/src/RamseyUuid/composer.json @@ -30,7 +30,7 @@ "phpspec/prophecy-phpunit": "^2.2", "ramsey/uuid": "^4.7", "ramsey/uuid-doctrine": "^2.0", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/type-info": "^7.3 || ^8.0" }, "autoload": { @@ -65,11 +65,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Serializer/Mapping/Loader/PropertyMetadataLoader.php b/src/Serializer/Mapping/Loader/PropertyMetadataLoader.php index 5c25996bdf3..408ffdb0c4e 100644 --- a/src/Serializer/Mapping/Loader/PropertyMetadataLoader.php +++ b/src/Serializer/Mapping/Loader/PropertyMetadataLoader.php @@ -61,7 +61,13 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool $attributesMetadata = $classMetadata->getAttributesMetadata(); foreach ($refl->getAttributes() as $a) { + // Skip attributes whose classes don't exist (e.g., optional dependencies like MongoDB ODM) + if (!class_exists($a->getName()) && !interface_exists($a->getName())) { + continue; + } + $attribute = $a->newInstance(); + if ($attribute instanceof DiscriminatorMap) { $classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping( method_exists($attribute, 'getTypeProperty') ? $attribute->getTypeProperty() : $attribute->typeProperty, diff --git a/src/Serializer/composer.json b/src/Serializer/composer.json index 7341fcfa431..b6005860cfd 100644 --- a/src/Serializer/composer.json +++ b/src/Serializer/composer.json @@ -38,7 +38,7 @@ "api-platform/openapi": "^4.2", "doctrine/collections": "^2.1", "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/mercure-bundle": "*", "symfony/var-dumper": "^6.4 || ^7.0 || ^8.0", "symfony/yaml": "^6.4 || ^7.0 || ^8.0", @@ -83,11 +83,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/State/composer.json b/src/State/composer.json index 591b1e72e4b..87940754b96 100644 --- a/src/State/composer.json +++ b/src/State/composer.json @@ -38,7 +38,7 @@ "require-dev": { "api-platform/serializer": "^4.2.4", "api-platform/validator": "^4.2.4", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/http-foundation": "^6.4.14 || ^7.0 || ^8.0", "symfony/object-mapper": "^7.4 || ^8.0", "symfony/type-info": "^7.4 || ^8.0", @@ -90,11 +90,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Symfony/composer.json b/src/Symfony/composer.json index ecacfbe38c7..1d6b64d322c 100644 --- a/src/Symfony/composer.json +++ b/src/Symfony/composer.json @@ -55,7 +55,7 @@ "api-platform/graphql": "^4.2.3", "api-platform/hal": "^4.2.3", "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev", + "phpunit/phpunit": "^12.2", "symfony/expression-language": "^6.4 || ^7.0 || ^8.0", "symfony/intl": "^6.4 || ^7.0 || ^8.0", "symfony/mercure-bundle": "*", @@ -119,11 +119,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/src/Validator/composer.json b/src/Validator/composer.json index 90b160b1c2f..6d89e87c5ac 100644 --- a/src/Validator/composer.json +++ b/src/Validator/composer.json @@ -32,7 +32,7 @@ }, "require-dev": { "phpspec/prophecy-phpunit": "^2.2", - "phpunit/phpunit": "11.5.x-dev" + "phpunit/phpunit": "^12.2" }, "autoload": { "psr-4": { @@ -66,11 +66,5 @@ }, "scripts": { "test": "./vendor/bin/phpunit" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/soyuka/phpunit" - } - ] + } } diff --git a/tests/Fixtures/TestBundle/ApiResource/AgentApi.php b/tests/Fixtures/TestBundle/ApiResource/AgentApi.php index 9d040921bb1..fc4bca059a7 100644 --- a/tests/Fixtures/TestBundle/ApiResource/AgentApi.php +++ b/tests/Fixtures/TestBundle/ApiResource/AgentApi.php @@ -13,15 +13,12 @@ namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource; -use ApiPlatform\Doctrine\Odm\Filter\DateFilter as OdmDateFilter; -use ApiPlatform\Doctrine\Odm\State\Options as OdmOptions; use ApiPlatform\Doctrine\Orm\Filter\DateFilter; use ApiPlatform\Doctrine\Orm\State\Options; use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\QueryParameter; -use ApiPlatform\Tests\Fixtures\TestBundle\Document\AgentDocument; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Agent; #[ApiFilter(DateFilter::class, properties: ['birthday'], alias: 'app_filter_date')] @@ -34,16 +31,6 @@ ], stateOptions: new Options(entityClass: Agent::class) )] -#[ApiFilter(OdmDateFilter::class, properties: ['birthday'], alias: 'app_filter_date_odm')] -#[ApiResource( - shortName: 'AgentDocument', - operations: [ - new GetCollection(parameters: [ - 'birthday' => new QueryParameter(filter: 'app_filter_date_odm'), - ]), - ], - stateOptions: new OdmOptions(documentClass: AgentDocument::class) -)] class AgentApi { private ?int $id = null; diff --git a/tests/Fixtures/TestBundle/ApiResourceOdm/AgentDocumentApi.php b/tests/Fixtures/TestBundle/ApiResourceOdm/AgentDocumentApi.php new file mode 100644 index 00000000000..aea8b646f1b --- /dev/null +++ b/tests/Fixtures/TestBundle/ApiResourceOdm/AgentDocumentApi.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResourceOdm; + +use ApiPlatform\Doctrine\Odm\Filter\DateFilter as OdmDateFilter; +use ApiPlatform\Doctrine\Odm\State\Options as OdmOptions; +use ApiPlatform\Metadata\ApiFilter; +use ApiPlatform\Metadata\ApiResource; +use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\QueryParameter; +use ApiPlatform\Tests\Fixtures\TestBundle\Document\AgentDocument; + +#[ApiFilter(OdmDateFilter::class, properties: ['birthday'], alias: 'app_filter_date_odm')] +#[ApiResource( + shortName: 'AgentDocument', + operations: [ + new GetCollection(parameters: [ + 'birthday' => new QueryParameter(filter: 'app_filter_date_odm'), + ]), + ], + stateOptions: new OdmOptions(documentClass: AgentDocument::class) +)] +class AgentDocumentApi +{ + private ?int $id = null; + + private ?string $name = null; + + private ?\DateTimeInterface $birthday = null; + + public function getId(): ?int + { + return $this->id; + } + + public function setId(?int $id): self + { + $this->id = $id; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + + return $this; + } + + public function getBirthday(): ?\DateTimeInterface + { + return $this->birthday; + } + + public function setBirthday(?\DateTimeInterface $birthday): self + { + $this->birthday = $birthday; + + return $this; + } +} diff --git a/tests/Fixtures/TestBundle/ApiResource/ResourceWithSeparatedDocument.php b/tests/Fixtures/TestBundle/ApiResourceOdm/ResourceWithSeparatedDocument.php similarity index 92% rename from tests/Fixtures/TestBundle/ApiResource/ResourceWithSeparatedDocument.php rename to tests/Fixtures/TestBundle/ApiResourceOdm/ResourceWithSeparatedDocument.php index bcf1fbc06d3..b0e2a6bebbf 100644 --- a/tests/Fixtures/TestBundle/ApiResource/ResourceWithSeparatedDocument.php +++ b/tests/Fixtures/TestBundle/ApiResourceOdm/ResourceWithSeparatedDocument.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource; +namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResourceOdm; use ApiPlatform\Doctrine\Odm\Filter\OrderFilter; use ApiPlatform\Doctrine\Odm\State\Options as ODMOptions; diff --git a/tests/Fixtures/app/AppKernel.php b/tests/Fixtures/app/AppKernel.php index 2a74b0d9b13..a4e7a595086 100644 --- a/tests/Fixtures/app/AppKernel.php +++ b/tests/Fixtures/app/AppKernel.php @@ -314,7 +314,10 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [ if ('mongodb' === $this->environment) { $c->prependExtensionConfig('api_platform', [ 'mapping' => [ - 'paths' => ['%kernel.project_dir%/../TestBundle/Resources/config/api_resources_odm'], + 'paths' => [ + '%kernel.project_dir%/../TestBundle/Resources/config/api_resources_odm', + '%kernel.project_dir%/../TestBundle/ApiResourceOdm', + ], ], ]); diff --git a/tests/Fixtures/app/config/config_common.yml b/tests/Fixtures/app/config/config_common.yml index eb58c616ae8..fcd716c59fb 100644 --- a/tests/Fixtures/app/config/config_common.yml +++ b/tests/Fixtures/app/config/config_common.yml @@ -443,10 +443,6 @@ services: tags: - name: 'api_platform.doctrine.orm.links_handler' - ApiPlatform\Tests\Fixtures\TestBundle\State\ODMLinkHandledDummyLinksHandler: - tags: - - name: 'api_platform.doctrine.odm.links_handler' - ApiPlatform\Tests\Fixtures\TestBundle\Serializer\ErrorNormalizer: arguments: [ '@serializer.normalizer.problem' ] tags: diff --git a/tests/Fixtures/app/config/config_mongodb.yml b/tests/Fixtures/app/config/config_mongodb.yml index f948ea309b8..119f96888fe 100644 --- a/tests/Fixtures/app/config/config_mongodb.yml +++ b/tests/Fixtures/app/config/config_mongodb.yml @@ -26,6 +26,8 @@ api_platform: mapping: paths: - '%kernel.project_dir%/../TestBundle/Model' + - '%kernel.project_dir%/../TestBundle/ApiResourceOdm/AgentDocumentApi.php' + - '%kernel.project_dir%/../TestBundle/ApiResourceOdm/ResourceWithSeparatedDocument.php' services: app.my_dummy_resource.mongodb.boolean_filter: @@ -177,3 +179,7 @@ services: ApiPlatform\Tests\Fixtures\TestBundle\Filter\QueryParameterOdmFilter: tags: [ 'api_platform.filter' ] + + ApiPlatform\Tests\Fixtures\TestBundle\State\ODMLinkHandledDummyLinksHandler: + tags: + - name: 'api_platform.doctrine.odm.links_handler' diff --git a/tests/Functional/Parameters/BooleanFilterTest.php b/tests/Functional/Parameters/BooleanFilterTest.php index 6a2a9e553a2..a856ea33790 100644 --- a/tests/Functional/Parameters/BooleanFilterTest.php +++ b/tests/Functional/Parameters/BooleanFilterTest.php @@ -92,9 +92,9 @@ public function testBooleanFilterWithNullAndEmptyValues(string $url): void public static function booleanFilterNullAndEmptyScenariosProvider(): \Generator { yield 'active_null_value' => ['/filtered_boolean_parameters?active=null']; - yield 'active_empty_value' => ['/filtered_boolean_parameters?active=', 3]; + yield 'active_empty_value' => ['/filtered_boolean_parameters?active=']; yield 'enabled_alias_null_value' => ['/filtered_boolean_parameters?enabled=null']; - yield 'enabled_alias_empty_value' => ['/filtered_boolean_parameters?enabled=', 3]; + yield 'enabled_alias_empty_value' => ['/filtered_boolean_parameters?enabled=']; } /** diff --git a/tests/Functional/Parameters/QueryParameterStateOptionsTest.php b/tests/Functional/Parameters/QueryParameterStateOptionsTest.php index 408b5310622..6c2cdd384e5 100644 --- a/tests/Functional/Parameters/QueryParameterStateOptionsTest.php +++ b/tests/Functional/Parameters/QueryParameterStateOptionsTest.php @@ -15,6 +15,7 @@ use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\AgentApi; +use ApiPlatform\Tests\Fixtures\TestBundle\ApiResourceOdm\AgentDocumentApi; use ApiPlatform\Tests\Fixtures\TestBundle\Document\AgentDocument; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Agent; use ApiPlatform\Tests\SetupClassResourcesTrait; @@ -33,7 +34,13 @@ final class QueryParameterStateOptionsTest extends ApiTestCase */ public static function getResources(): array { - return [AgentApi::class]; + $resources = [AgentApi::class]; + + if (class_exists(DocumentManager::class)) { + $resources[] = AgentDocumentApi::class; + } + + return $resources; } public function testQueryParameterStateOptions(): void