-
-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(metadata): _format broken bc promise on #5080 * add deprecation contracts * fix phpstan
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/Fixtures/TestBundle/ApiResourceNotLoaded/SymfonyFormatParameterLegacy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* 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\ApiResourceNotLoaded; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
|
||
#[ApiResource('/format_not_rfc.{_format}')] | ||
class SymfonyFormatParameterLegacy | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,22 +23,26 @@ | |
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface; | ||
use ApiPlatform\Metadata\Property\PropertyNameCollection; | ||
use ApiPlatform\Metadata\Put; | ||
use ApiPlatform\Metadata\Resource\Factory\AttributesResourceMetadataCollectionFactory; | ||
use ApiPlatform\Metadata\Resource\Factory\LinkFactory; | ||
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; | ||
use ApiPlatform\Metadata\Resource\Factory\UriTemplateResourceMetadataCollectionFactory; | ||
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; | ||
use ApiPlatform\Operation\PathSegmentNameGeneratorInterface; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResourceNotLoaded\SymfonyFormatParameterLegacy; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\AttributeResource; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy; | ||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Argument; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; | ||
|
||
/** | ||
* @author Antoine Bluchet <[email protected]> | ||
*/ | ||
class UriTemplateResourceMetadataCollectionFactoryTest extends TestCase | ||
{ | ||
use ExpectDeprecationTrait; | ||
use ProphecyTrait; | ||
|
||
public function testCreate(): void | ||
|
@@ -169,4 +173,25 @@ class: AttributeResource::class, | |
$uriTemplateResourceMetadataCollectionFactory->create(AttributeResource::class) | ||
); | ||
} | ||
|
||
/** | ||
* @group legacy | ||
*/ | ||
public function testCreateWithLegacyFormat(): void | ||
{ | ||
$this->expectDeprecation('Since api-platform/core 3.0: The special Symfony parameter ".{_format}" in your URI Template is deprecated, use an RFC6570 variable "{._format}" on the class "ApiPlatform\Tests\Fixtures\TestBundle\ApiResourceNotLoaded\SymfonyFormatParameterLegacy" instead. We will only use the RFC6570 compatible variable in 4.0.'); | ||
|
||
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class); | ||
$propertyNameCollectionFactoryProphecy->create(Argument::cetera())->willReturn(new PropertyNameCollection()); | ||
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class); | ||
$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class); | ||
$linkFactory = new LinkFactory($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceClassResolverProphecy->reveal()); | ||
$pathSegmentNameGeneratorProphecy = $this->prophesize(PathSegmentNameGeneratorInterface::class); | ||
$pathSegmentNameGeneratorProphecy->getSegmentName('SymfonyFormatParameterLegacy')->willReturn('attribute_resources'); | ||
$resourceCollectionMetadataFactoryProphecy = new AttributesResourceMetadataCollectionFactory(); | ||
|
||
$linkFactory = new LinkFactory($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceClassResolverProphecy->reveal()); | ||
$uriTemplateResourceMetadataCollectionFactory = new UriTemplateResourceMetadataCollectionFactory($linkFactory, $pathSegmentNameGeneratorProphecy->reveal(), $resourceCollectionMetadataFactoryProphecy); | ||
$uriTemplateResourceMetadataCollectionFactory->create(SymfonyFormatParameterLegacy::class); | ||
} | ||
} |