Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 754e534

Browse files
authored
Merge pull request #78 from symfony-cmf/jms-serializer-2-3
Jms serializer 2 3
2 parents 29705ed + 1adb254 commit 754e534

File tree

7 files changed

+25
-16
lines changed

7 files changed

+25
-16
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
"require": {
1313
"php": "^7.2",
1414
"symfony-cmf/resource-bundle": "^1.0",
15-
"jms/serializer-bundle": "^1.0 | ^2.0 | ^3.0",
15+
"jms/serializer-bundle": "^2.0 || ^3.0",
1616
"symfony/translation": "^2.8 || ^3.3 || ^4.0"
1717
},
1818
"require-dev": {
1919
"symfony-cmf/testing": "^2.1@dev",
2020
"symfony/phpunit-bridge": "^5",
2121
"doctrine/phpcr-odm": "^1.4|^2.0",
22-
"jms/serializer": "^1.2",
2322
"behat/behat": "^3.0.6",
2423
"imbo/behat-api-extension": "^2.1",
2524
"matthiasnoback/symfony-dependency-injection-test": "^4",
@@ -54,6 +53,7 @@
5453
}
5554
},
5655
"conflict": {
56+
"jms/serializer": "<2.2.0",
5757
"sebastian/environment": "<1.3.4",
5858
"sebastian/exporter": "<2.0.0"
5959
},

phpunit.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@
2020
</exclude>
2121
</whitelist>
2222
</filter>
23+
24+
<php>
25+
<env name="SYMFONY_PHPUNIT_VERSION" value="8.5"/>
26+
</php>
27+
2328
</phpunit>

src/Serializer/Jms/Handler/PhpcrNodeHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use JMS\Serializer\Context;
1515
use JMS\Serializer\GraphNavigator;
1616
use JMS\Serializer\Handler\SubscribingHandlerInterface;
17-
use JMS\Serializer\JsonSerializationVisitor;
17+
use JMS\Serializer\Visitor\SerializationVisitorInterface;
1818
use PHPCR\NodeInterface;
1919

2020
/**
@@ -40,7 +40,7 @@ public static function getSubscribingMethods()
4040
* @param NodeInterface $nodeInterface
4141
*/
4242
public function serializePhpcrNode(
43-
JsonSerializationVisitor $visitor,
43+
SerializationVisitorInterface $visitor,
4444
NodeInterface $node,
4545
array $type,
4646
Context $context

src/Serializer/Jms/Handler/ResourceHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use JMS\Serializer\Context;
1515
use JMS\Serializer\GraphNavigator;
1616
use JMS\Serializer\Handler\SubscribingHandlerInterface;
17-
use JMS\Serializer\JsonSerializationVisitor;
17+
use JMS\Serializer\Visitor\SerializationVisitorInterface;
1818
use PHPCR\NodeInterface;
1919
use PHPCR\Util\PathHelper;
2020
use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\PayloadAliasRegistry;
@@ -70,13 +70,13 @@ public static function getSubscribingMethods()
7070
* @param NodeInterface $resourceInterface
7171
*/
7272
public function serializeResource(
73-
JsonSerializationVisitor $visitor,
73+
SerializationVisitorInterface $visitor,
7474
PuliResource $resource,
7575
array $type,
7676
Context $context
7777
) {
7878
$data = $this->doSerializeResource($resource);
79-
$context->accept($data);
79+
$context->getNavigator()->accept($data);
8080
}
8181

8282
public function setMaxDepth($maxDepth)

tests/Unit/DependencyInjection/CmfResourceRestExtensionTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ public function testExtension($config)
4949
$this->compile();
5050
}
5151

52-
/**
53-
* @expectedException \LogicException
54-
* @expectedExceptionMessage The JMSSerializerBundle must be registered
55-
*/
5652
public function testNoJmsSerializerBundleRegistered()
5753
{
5854
$this->container->setParameter('kernel.bundles', []);
5955

56+
$this->expectException(\LogicException::class);
57+
$this->expectExceptionMessage('The JMSSerializerBundle must be registered');
58+
6059
$this->load([]);
61-
$this->compile();
6260
}
6361
}

tests/Unit/Serializer/Jms/Handler/PhpcrNodeHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Unit\Serializer\Jms\Handler;
1313

14+
use JMS\Serializer\Visitor\SerializationVisitorInterface;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Cmf\Bundle\ResourceRestBundle\Serializer\Jms\Handler\PhpcrNodeHandler;
1617

@@ -29,7 +30,7 @@ public function setUp(): void
2930
$this->node = $this->prophesize('PHPCR\NodeInterface');
3031
$this->property1 = $this->prophesize('PHPCR\PropertyInterface');
3132
$this->property2 = $this->prophesize('PHPCR\PropertyInterface');
32-
$this->visitor = $this->prophesize('JMS\Serializer\JsonSerializationVisitor');
33+
$this->visitor = $this->prophesize(SerializationVisitorInterface::class);
3334
$this->context = $this->prophesize('JMS\Serializer\Context');
3435
$this->handler = new PhpcrNodeHandler();
3536
}

tests/Unit/Serializer/Jms/Handler/ResourceHandlerTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Unit\Serializer\Jms\Handler;
1313

1414
use JMS\Serializer\Context;
15-
use JMS\Serializer\JsonSerializationVisitor;
15+
use JMS\Serializer\GraphNavigatorInterface;
16+
use JMS\Serializer\Visitor\SerializationVisitorInterface;
1617
use PHPUnit\Framework\TestCase;
1718
use Prophecy\Argument;
1819
use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\PayloadAliasRegistry;
@@ -45,16 +46,19 @@ class ResourceHandlerTest extends TestCase
4546

4647
private $description;
4748

49+
private $navigator;
50+
4851
protected function setUp(): void
4952
{
5053
$this->repositoryRegistry = $this->prophesize(RepositoryRegistryInterface::class);
5154
$this->payloadAliasRegistry = $this->prophesize(PayloadAliasRegistry::class);
52-
$this->visitor = $this->prophesize(JsonSerializationVisitor::class);
55+
$this->visitor = $this->prophesize(SerializationVisitorInterface::class);
5356
$this->resource = $this->prophesize(CmfResource::class);
5457
$this->childResource = $this->prophesize(CmfResource::class);
5558

5659
$this->repository = $this->prophesize(ResourceRepository::class);
5760
$this->context = $this->prophesize(Context::class);
61+
$this->navigator = $this->prophesize(GraphNavigatorInterface::class);
5862

5963
$this->description = $this->prophesize(Description::class);
6064
$this->description->all()->willReturn([]);
@@ -118,7 +122,8 @@ public function testHandler()
118122
'descriptors' => [],
119123
];
120124

121-
$this->context->accept($expected)->shouldBeCalled();
125+
$this->context->getNavigator()->willReturn($this->navigator);
126+
$this->navigator->accept($expected)->willReturn($this->context);
122127

123128
$this->handler->serializeResource(
124129
$this->visitor->reveal(),

0 commit comments

Comments
 (0)