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

Commit

Permalink
Merge pull request #78 from symfony-cmf/jms-serializer-2-3
Browse files Browse the repository at this point in the history
Jms serializer 2 3
  • Loading branch information
dbu committed Nov 16, 2020
2 parents 29705ed + 1adb254 commit 754e534
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
"require": {
"php": "^7.2",
"symfony-cmf/resource-bundle": "^1.0",
"jms/serializer-bundle": "^1.0 | ^2.0 | ^3.0",
"jms/serializer-bundle": "^2.0 || ^3.0",
"symfony/translation": "^2.8 || ^3.3 || ^4.0"
},
"require-dev": {
"symfony-cmf/testing": "^2.1@dev",
"symfony/phpunit-bridge": "^5",
"doctrine/phpcr-odm": "^1.4|^2.0",
"jms/serializer": "^1.2",
"behat/behat": "^3.0.6",
"imbo/behat-api-extension": "^2.1",
"matthiasnoback/symfony-dependency-injection-test": "^4",
Expand Down Expand Up @@ -54,6 +53,7 @@
}
},
"conflict": {
"jms/serializer": "<2.2.0",
"sebastian/environment": "<1.3.4",
"sebastian/exporter": "<2.0.0"
},
Expand Down
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
</exclude>
</whitelist>
</filter>

<php>
<env name="SYMFONY_PHPUNIT_VERSION" value="8.5"/>
</php>

</phpunit>
4 changes: 2 additions & 2 deletions src/Serializer/Jms/Handler/PhpcrNodeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use JMS\Serializer\Context;
use JMS\Serializer\GraphNavigator;
use JMS\Serializer\Handler\SubscribingHandlerInterface;
use JMS\Serializer\JsonSerializationVisitor;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use PHPCR\NodeInterface;

/**
Expand All @@ -40,7 +40,7 @@ public static function getSubscribingMethods()
* @param NodeInterface $nodeInterface
*/
public function serializePhpcrNode(
JsonSerializationVisitor $visitor,
SerializationVisitorInterface $visitor,
NodeInterface $node,
array $type,
Context $context
Expand Down
6 changes: 3 additions & 3 deletions src/Serializer/Jms/Handler/ResourceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use JMS\Serializer\Context;
use JMS\Serializer\GraphNavigator;
use JMS\Serializer\Handler\SubscribingHandlerInterface;
use JMS\Serializer\JsonSerializationVisitor;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use PHPCR\NodeInterface;
use PHPCR\Util\PathHelper;
use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\PayloadAliasRegistry;
Expand Down Expand Up @@ -70,13 +70,13 @@ public static function getSubscribingMethods()
* @param NodeInterface $resourceInterface
*/
public function serializeResource(
JsonSerializationVisitor $visitor,
SerializationVisitorInterface $visitor,
PuliResource $resource,
array $type,
Context $context
) {
$data = $this->doSerializeResource($resource);
$context->accept($data);
$context->getNavigator()->accept($data);
}

public function setMaxDepth($maxDepth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ public function testExtension($config)
$this->compile();
}

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

$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The JMSSerializerBundle must be registered');

$this->load([]);
$this->compile();
}
}
3 changes: 2 additions & 1 deletion tests/Unit/Serializer/Jms/Handler/PhpcrNodeHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

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

use JMS\Serializer\Visitor\SerializationVisitorInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Cmf\Bundle\ResourceRestBundle\Serializer\Jms\Handler\PhpcrNodeHandler;

Expand All @@ -29,7 +30,7 @@ public function setUp(): void
$this->node = $this->prophesize('PHPCR\NodeInterface');
$this->property1 = $this->prophesize('PHPCR\PropertyInterface');
$this->property2 = $this->prophesize('PHPCR\PropertyInterface');
$this->visitor = $this->prophesize('JMS\Serializer\JsonSerializationVisitor');
$this->visitor = $this->prophesize(SerializationVisitorInterface::class);
$this->context = $this->prophesize('JMS\Serializer\Context');
$this->handler = new PhpcrNodeHandler();
}
Expand Down
11 changes: 8 additions & 3 deletions tests/Unit/Serializer/Jms/Handler/ResourceHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Unit\Serializer\Jms\Handler;

use JMS\Serializer\Context;
use JMS\Serializer\JsonSerializationVisitor;
use JMS\Serializer\GraphNavigatorInterface;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\PayloadAliasRegistry;
Expand Down Expand Up @@ -45,16 +46,19 @@ class ResourceHandlerTest extends TestCase

private $description;

private $navigator;

protected function setUp(): void
{
$this->repositoryRegistry = $this->prophesize(RepositoryRegistryInterface::class);
$this->payloadAliasRegistry = $this->prophesize(PayloadAliasRegistry::class);
$this->visitor = $this->prophesize(JsonSerializationVisitor::class);
$this->visitor = $this->prophesize(SerializationVisitorInterface::class);
$this->resource = $this->prophesize(CmfResource::class);
$this->childResource = $this->prophesize(CmfResource::class);

$this->repository = $this->prophesize(ResourceRepository::class);
$this->context = $this->prophesize(Context::class);
$this->navigator = $this->prophesize(GraphNavigatorInterface::class);

$this->description = $this->prophesize(Description::class);
$this->description->all()->willReturn([]);
Expand Down Expand Up @@ -118,7 +122,8 @@ public function testHandler()
'descriptors' => [],
];

$this->context->accept($expected)->shouldBeCalled();
$this->context->getNavigator()->willReturn($this->navigator);
$this->navigator->accept($expected)->willReturn($this->context);

$this->handler->serializeResource(
$this->visitor->reveal(),
Expand Down

0 comments on commit 754e534

Please sign in to comment.