-
-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use serializer AbstractItemNormalizer constants when related
- Loading branch information
Showing
14 changed files
with
75 additions
and
61 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
use Symfony\Component\Serializer\Mapping\AttributeMetadata; | ||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; | ||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; | ||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; | ||
|
||
/** | ||
* @author Amrouche Hamza <[email protected]> | ||
|
@@ -315,7 +316,7 @@ public function testDenormalizeItemWithExistingGroups() | |
$queryBuilderProphecy->getEntityManager()->willReturn($emProphecy); | ||
|
||
$eagerExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false, null, null, true); | ||
$eagerExtensionTest->applyToItem($queryBuilderProphecy->reveal(), new QueryNameGenerator(), RelatedDummy::class, ['id' => 1], 'item_operation', ['groups' => 'some_groups']); | ||
$eagerExtensionTest->applyToItem($queryBuilderProphecy->reveal(), new QueryNameGenerator(), RelatedDummy::class, ['id' => 1], 'item_operation', [AbstractNormalizer::GROUPS => 'some_groups']); | ||
} | ||
|
||
/** | ||
|
@@ -442,7 +443,7 @@ public function testMaxDepth() | |
public function testForceEager() | ||
{ | ||
$resourceMetadata = new ResourceMetadata(); | ||
$resourceMetadata = $resourceMetadata->withAttributes(['normalization_context' => ['groups' => 'foobar']]); | ||
$resourceMetadata = $resourceMetadata->withAttributes(['normalization_context' => [AbstractNormalizer::GROUPS => 'foobar']]); | ||
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class); | ||
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn($resourceMetadata); | ||
|
||
|
@@ -617,7 +618,7 @@ public function testApplyToCollectionWithSerializerContextBuilder() | |
$requestStack->push($request); | ||
|
||
$serializerContextBuilderProphecy = $this->prophesize(SerializerContextBuilderInterface::class); | ||
$serializerContextBuilderProphecy->createFromRequest($request, true)->shouldBeCalled()->willReturn(['groups' => ['foo']]); | ||
$serializerContextBuilderProphecy->createFromRequest($request, true)->shouldBeCalled()->willReturn([AbstractNormalizer::GROUPS => ['foo']]); | ||
|
||
$queryBuilder = $queryBuilderProphecy->reveal(); | ||
$eagerExtensionTest = new EagerLoadingExtension($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $resourceMetadataFactoryProphecy->reveal(), 30, false, $requestStack, $serializerContextBuilderProphecy->reveal(), true); | ||
|
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 |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
use Prophecy\Argument; | ||
use Symfony\Component\PropertyInfo\Type; | ||
use Symfony\Component\Serializer\NameConverter\NameConverterInterface; | ||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; | ||
|
||
/** | ||
* @author Teoh Han Hui <[email protected]> | ||
|
@@ -94,8 +95,8 @@ public function testSupportsAttributeNormalization() | |
{ | ||
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class); | ||
$resourceMetadataFactoryProphecy->create('Acme\CustomAttributeDummy')->willReturn(new ResourceMetadata('dummy', 'dummy', null, [ | ||
'get' => ['method' => 'GET', 'normalization_context' => ['groups' => ['custom_attr_dummy_get']]], | ||
'put' => ['method' => 'PUT', 'denormalization_context' => ['groups' => ['custom_attr_dummy_put']]], | ||
'get' => ['method' => 'GET', 'normalization_context' => [AbstractNormalizer::GROUPS => ['custom_attr_dummy_get']]], | ||
'put' => ['method' => 'PUT', 'denormalization_context' => [AbstractNormalizer::GROUPS => ['custom_attr_dummy_put']]], | ||
'delete' => ['method' => 'DELETE'], | ||
], []))->shouldBeCalled(); | ||
$resourceMetadataFactory = $resourceMetadataFactoryProphecy->reveal(); | ||
|
@@ -189,9 +190,9 @@ public function testParse() | |
{ | ||
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class); | ||
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata('dummy', 'dummy', null, [ | ||
'get' => ['method' => 'GET', 'normalization_context' => ['groups' => ['custom_attr_dummy_get']]], | ||
'put' => ['method' => 'PUT', 'denormalization_context' => ['groups' => ['custom_attr_dummy_put']]], | ||
'gerard' => ['method' => 'get', 'path' => '/gerard', 'denormalization_context' => ['groups' => ['custom_attr_dummy_put']]], | ||
'get' => ['method' => 'GET', 'normalization_context' => [AbstractNormalizer::GROUPS => ['custom_attr_dummy_get']]], | ||
'put' => ['method' => 'PUT', 'denormalization_context' => [AbstractNormalizer::GROUPS => ['custom_attr_dummy_put']]], | ||
'gerard' => ['method' => 'get', 'path' => '/gerard', 'denormalization_context' => [AbstractNormalizer::GROUPS => ['custom_attr_dummy_put']]], | ||
'delete' => ['method' => 'DELETE'], | ||
], []))->shouldBeCalled(); | ||
$resourceMetadataFactory = $resourceMetadataFactoryProphecy->reveal(); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
use Symfony\Component\Serializer\Mapping\AttributeMetadata as SerializerAttributeMetadata; | ||
use Symfony\Component\Serializer\Mapping\ClassMetadata as SerializerClassMetadata; | ||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface as SerializerClassMetadataFactoryInterface; | ||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; | ||
|
||
/** | ||
* @author Teoh Han Hui <[email protected]> | ||
|
@@ -55,10 +56,10 @@ public function testCreate() | |
$dummyResourceMetadata = (new ResourceMetadata()) | ||
->withAttributes([ | ||
'normalization_context' => [ | ||
'groups' => ['dummy_read'], | ||
AbstractNormalizer::GROUPS => ['dummy_read'], | ||
], | ||
'denormalization_context' => [ | ||
'groups' => ['dummy_write'], | ||
AbstractNormalizer::GROUPS => ['dummy_write'], | ||
], | ||
]); | ||
$resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn($dummyResourceMetadata)->shouldBeCalled(); | ||
|
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
Oops, something went wrong.