Skip to content

Commit fe04d6f

Browse files
committed
Fix tests and deprecations
1 parent 72ac53a commit fe04d6f

File tree

7 files changed

+69
-9
lines changed

7 files changed

+69
-9
lines changed

src/Bridge/NelmioApiDoc/Extractor/AnnotationsProvider/ApiPlatformProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*
3333
* @author Kévin Dunglas <[email protected]>
3434
* @author Teoh Han Hui <[email protected]>
35+
*
36+
* @deprecated since version 2.2, to be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
3537
*/
3638
final class ApiPlatformProvider implements AnnotationsProviderInterface
3739
{
@@ -47,14 +49,14 @@ final class ApiPlatformProvider implements AnnotationsProviderInterface
4749
*/
4850
public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, NormalizerInterface $documentationNormalizer, ResourceMetadataFactoryInterface $resourceMetadataFactory, $filterLocator, OperationMethodResolverInterface $operationMethodResolver)
4951
{
52+
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);
53+
5054
$this->setFilterLocator($filterLocator);
5155

5256
$this->resourceNameCollectionFactory = $resourceNameCollectionFactory;
5357
$this->documentationNormalizer = $documentationNormalizer;
5458
$this->resourceMetadataFactory = $resourceMetadataFactory;
5559
$this->operationMethodResolver = $operationMethodResolver;
56-
57-
@trigger_error('The '.__NAMESPACE__.'\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);
5860
}
5961

6062
/**

src/Bridge/NelmioApiDoc/Parser/ApiPlatformParser.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*
3030
* @author Kévin Dunglas <[email protected]>
3131
* @author Teoh Han Hui <[email protected]>
32+
*
33+
* @deprecated since version 2.2, to be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
3234
*/
3335
final class ApiPlatformParser implements ParserInterface
3436
{
@@ -49,12 +51,12 @@ final class ApiPlatformParser implements ParserInterface
4951

5052
public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFactory, PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, NameConverterInterface $nameConverter = null)
5153
{
54+
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);
55+
5256
$this->resourceMetadataFactory = $resourceMetadataFactory;
5357
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
5458
$this->propertyMetadataFactory = $propertyMetadataFactory;
5559
$this->nameConverter = $nameConverter;
56-
57-
@trigger_error('The '.__NAMESPACE__.'\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 2 has native support for API Platform.', E_USER_DEPRECATED);
5860
}
5961

6062
/**

src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ public function getConfigTreeBuilder()
6666
->end()
6767
->end()
6868
->booleanNode('enable_fos_user')->defaultValue(class_exists(FOSUserBundle::class))->info('Enable the FOSUserBundle integration.')->end()
69-
->booleanNode('enable_nelmio_api_doc')->defaultValue(false)->info('Enable the Nelmio Api doc integration.')->end()
69+
->booleanNode('enable_nelmio_api_doc')
70+
->beforeNormalization()->always(function ($v) {
71+
if ($v) {
72+
@trigger_error('Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);
73+
}
74+
75+
return $v;
76+
})->end()
77+
->defaultValue(false)
78+
->info('[Deprecated] Enable the NelmioApiDocBundle integration.')
79+
->end()
7080
->booleanNode('enable_swagger')->defaultValue(true)->info('Enable the Swagger documentation and export.')->end()
7181
->booleanNode('enable_swagger_ui')->defaultValue(class_exists(TwigBundle::class))->info('Enable Swagger ui.')->end()
7282

src/Bridge/Symfony/Bundle/Resources/config/nelmio_api_doc.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
<services>
88
<service id="api_platform.nelmio_api_doc.annotations_provider" class="ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider">
9+
<deprecated>The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.</deprecated>
10+
911
<argument type="service" id="api_platform.metadata.resource.name_collection_factory" />
1012
<argument type="service" id="api_platform.hydra.normalizer.documentation" />
1113
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
@@ -16,6 +18,8 @@
1618
</service>
1719

1820
<service id="api_platform.nelmio_api_doc.parser" class="ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser">
21+
<deprecated>The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.</deprecated>
22+
1923
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
2024
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
2125
<argument type="service" id="api_platform.metadata.property.metadata_factory" />

tests/Bridge/NelmioApiDoc/Extractor/AnnotationsProvider/ApiPlatformProviderTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
* @author Teoh Han Hui <[email protected]>
3535
*
3636
* @group legacy
37-
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
3837
*/
3938
class ApiPlatformProviderTest extends \PHPUnit_Framework_TestCase
4039
{
40+
/**
41+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
42+
*/
4143
public function testConstruct()
4244
{
4345
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
@@ -60,6 +62,9 @@ public function testConstruct()
6062
$this->assertInstanceOf(AnnotationsProviderInterface::class, $apiPlatformProvider);
6163
}
6264

65+
/**
66+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
67+
*/
6368
public function testGetAnnotations()
6469
{
6570
$dummySearchFilterProphecy = $this->prophesize(FilterInterface::class);
@@ -80,7 +85,7 @@ public function testGetAnnotations()
8085
}
8186

8287
/**
83-
* @group legacy
88+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
8489
* @expectedDeprecation The ApiPlatform\Core\Api\FilterCollection class is deprecated since version 2.1 and will be removed in 3.0. Provide an implementation of Psr\Container\ContainerInterface instead.
8590
*/
8691
public function testGetAnnotationsWithDeprecatedFilterCollection()
@@ -99,7 +104,8 @@ public function testGetAnnotationsWithDeprecatedFilterCollection()
99104
}
100105

101106
/**
102-
* @group legacy
107+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
108+
*
103109
* @expectedException \InvalidArgumentException
104110
* @expectedExceptionMessage The "$filterLocator" argument is expected to be an implementation of the "Psr\Container\ContainerInterface" interface.
105111
*/

tests/Bridge/NelmioApiDoc/Parser/ApiPlatformParserTest.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
* @author Teoh Han Hui <[email protected]>
3535
*
3636
* @group legacy
37-
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
3837
*/
3938
class ApiPlatformParserTest extends \PHPUnit_Framework_TestCase
4039
{
40+
/**
41+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
42+
*/
4143
public function testConstruct()
4244
{
4345
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -54,6 +56,9 @@ public function testConstruct()
5456
$this->assertInstanceOf(ParserInterface::class, $apiPlatformParser);
5557
}
5658

59+
/**
60+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
61+
*/
5762
public function testSupports()
5863
{
5964
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -73,6 +78,9 @@ public function testSupports()
7378
]));
7479
}
7580

81+
/**
82+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
83+
*/
7684
public function testNoOnDataFirstArray()
7785
{
7886
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -92,6 +100,9 @@ public function testNoOnDataFirstArray()
92100
]));
93101
}
94102

103+
/**
104+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
105+
*/
95106
public function testSupportsAttributeNormalization()
96107
{
97108
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -149,6 +160,9 @@ public function testSupportsAttributeNormalization()
149160
], $actual);
150161
}
151162

163+
/**
164+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
165+
*/
152166
public function testSupportsUnknownResource()
153167
{
154168
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -168,6 +182,9 @@ public function testSupportsUnknownResource()
168182
]));
169183
}
170184

185+
/**
186+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
187+
*/
171188
public function testSupportsUnsupportedClassFormat()
172189
{
173190
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -187,6 +204,9 @@ public function testSupportsUnsupportedClassFormat()
187204
]));
188205
}
189206

207+
/**
208+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
209+
*/
190210
public function testParse()
191211
{
192212
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -258,6 +278,9 @@ public function testParse()
258278
], $actual);
259279
}
260280

281+
/**
282+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
283+
*/
261284
public function testParseDateTime()
262285
{
263286
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -297,6 +320,9 @@ public function testParseDateTime()
297320
], $actual);
298321
}
299322

323+
/**
324+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
325+
*/
300326
public function testParseRelation()
301327
{
302328
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -385,6 +411,9 @@ public function testParseRelation()
385411
], $actual);
386412
}
387413

414+
/**
415+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
416+
*/
388417
public function testParseWithNameConverter()
389418
{
390419
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
@@ -427,6 +456,9 @@ public function testParseWithNameConverter()
427456
], $actual);
428457
}
429458

459+
/**
460+
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
461+
*/
430462
public function testParseRecursive()
431463
{
432464
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);

tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ public function testFosUserPriority()
206206
);
207207
}
208208

209+
/**
210+
* @group legacy
211+
* @expectedDeprecation Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
212+
*/
209213
public function testEnableNelmioApiDoc()
210214
{
211215
$containerBuilderProphecy = $this->getContainerBuilderProphecy();

0 commit comments

Comments
 (0)