Skip to content

Commit

Permalink
test update
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Nov 8, 2024
1 parent 6e6c4c0 commit ea5ef80
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 6 deletions.
6 changes: 5 additions & 1 deletion phpunit-ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
/^Since nelmio\/api-doc-bundle 4\.17\.0: Using the \$groups parameter of "Nelmio\\ApiDocBundle\\PropertyDescriber\\(PropertyDescriber|IntegerPropertyDescriber|NullablePropertyDescriber|StringPropertyDescriber|ObjectPropertyDescriber)::describe\(\)" is deprecated/

# Ignoring deprecations from Nelmio\ApiDocBundle 4.32.3
/^Since nelmio\/api-doc-bundle 4\.32\.3: The "Nelmio\\ApiDocBundle\\Annotation\\(Operation|Security|Areas|Model)" class is deprecated and will be removed in 5\.0\. Use the "\\Nelmio\\ApiDocBundle\\Attribute\\(Operation|Security|Areas|Model)" attribute instead\./
/^Since nelmio\/api-doc-bundle 4\.32\.3: The "Nelmio\\ApiDocBundle\\Annotation\\(Operation|Security|Areas|Model)" class is deprecated and will be removed in 5\.0\. Use the "\\Nelmio\\ApiDocBundle\\Attribute\\(Operation|Security|Areas|Model)" attribute instead\./

# Ignoring deprecations from Nelmio\ApiDocBundle 4.33.4
/^Since nelmio\/api-doc-bundle 4\.33\.4: Passing null to the "\$options" argument of "Nelmio\\ApiDocBundle\\Model\\Model\:\:\_\_construct\(\)" is deprecated\, pass an empty array instead\./
/^Since nelmio\/api-doc-bundle 4\.33\.4: Passing null to the "\$options" argument of "Nelmio\\ApiDocBundle\\Attribute\\Model\:\:\_\_construct\(\)" is deprecated\, pass an empty array instead\./
30 changes: 30 additions & 0 deletions tests/Functional/Controller/DeprecationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;

use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article81;
use OpenApi\Attributes as OA;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;

class DeprecationController
{
#[Route(path: '/legacy/null_options', name: 'legacy_null_options', methods: 'POST')]
#[OA\Response(
response: 200,
content: new Model(type: Article81::class, options: null),
)]
public function __invoke(Article81 $requestDTO): JsonResponse
{
}
}
7 changes: 7 additions & 0 deletions tests/Functional/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public static function provideAttributeTestCases(): \Generator
[__DIR__.'/Configs/JMS.yaml'],
];

yield 'Deprecation null model options' => [
[
'name' => 'DeprecationController',
'type' => $type,
],
];

if (version_compare(Kernel::VERSION, '6.3.0', '>=')) {
yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2209' => [
[
Expand Down
85 changes: 85 additions & 0 deletions tests/Functional/Fixtures/DeprecationController.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"openapi": "3.0.0",
"info": {
"title": "",
"version": "0.0.0"
},
"paths": {
"/legacy/null_options": {
"post": {
"operationId": "post_legacy_null_options",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Article81"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Article81": {
"required": [
"id",
"type",
"intBackedType",
"notBackedType"
],
"properties": {
"id": {
"type": "integer"
},
"type": {
"$ref": "#/components/schemas/ArticleType81"
},
"intBackedType": {
"$ref": "#/components/schemas/ArticleType81IntBacked"
},
"notBackedType": {
"$ref": "#/components/schemas/ArticleType81NotBacked"
},
"nullableType": {
"nullable": true,
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
]
}
},
"type": "object"
},
"ArticleType81": {
"type": "string",
"enum": [
"draft",
"final"
]
},
"ArticleType81IntBacked": {
"type": "integer",
"enum": [
0,
1
]
},
"ArticleType81NotBacked": {
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
}
}
5 changes: 0 additions & 5 deletions tests/Model/ModelRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public function testNameAliasingNotAppliedForCollections(): void
* @dataProvider provideNameCollisionsTypes
*
* @param array<string, mixed> $arrayType
*
* @group legacy
*/
public function testNameCollisionsAreLogged(Type $type, array $arrayType): void
{
Expand Down Expand Up @@ -112,9 +110,6 @@ public static function provideNameCollisionsTypes(): \Generator
];
}

/**
* @group legacy
*/
public function testNameCollisionsAreLoggedWithAlternativeNames(): void
{
$ref = new \ReflectionClass(self::class);
Expand Down

0 comments on commit ea5ef80

Please sign in to comment.