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

Commit 776f2f7

Browse files
Merge pull request #211 from symfony-cmf/next_try_remove_parameter
Next try remove parameter
2 parents 394d142 + 27e5ad1 commit 776f2f7

File tree

3 files changed

+64
-8
lines changed

3 files changed

+64
-8
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": "^5.6|^7.0",
1414
"symfony/framework-bundle": "^2.8|^3.0",
15-
"symfony-cmf/routing-auto": "2.0.0-RC2",
15+
"symfony-cmf/routing-auto": "^2.0.0-RC5",
1616
"symfony-cmf/routing-bundle": "^1.2.0|^2.0",
1717
"aferrandini/urlizer": "1.0.*",
1818
"phpdocumentor/reflection-docblock": "^3.1, !=3.2.0"

src/Adapter/PhpcrOdmAdapter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ public function removeAutoRoute(AutoRouteInterface $autoRoute)
111111
/**
112112
* {@inheritdoc}
113113
*/
114-
public function createAutoRoute(UriContext $uriContext, $contentDocument, $locale)
114+
public function createAutoRoute(UriContext $uriContext, $locale)
115115
{
116116
$basePath = $this->baseRoutePath;
117+
$contentDocument = $uriContext->getSubject();
117118
$document = $parentDocument = $this->dm->find(null, $basePath);
118119

119120
if (null === $parentDocument) {

tests/Unit/Adapter/PhpcrOdmAdapterTest.php

+61-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,63 @@
1111

1212
namespace Symfony\Cmf\Component\RoutingAuto\Tests\Unit\Adapter;
1313

14+
use Doctrine\ODM\PHPCR\DocumentManager;
15+
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
16+
use PHPCR\NodeInterface;
17+
use PHPCR\SessionInterface;
18+
use Prophecy\Prophecy\ObjectProphecy;
1419
use Symfony\Cmf\Bundle\RoutingAutoBundle\Adapter\PhpcrOdmAdapter;
20+
use Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface;
21+
use Symfony\Cmf\Component\RoutingAuto\UriContext;
22+
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1523

1624
class PhpcrOdmAdapterTest extends \PHPUnit_Framework_TestCase
1725
{
18-
protected $dm;
19-
protected $baseRoutePath;
26+
/**
27+
* @var DocumentManager|ObjectProphecy
28+
*/
29+
private $dm;
30+
31+
/**
32+
* @var ClassMetadataFactory|ObjectProphecy
33+
*/
34+
private $metadataFactory;
35+
36+
/**
37+
* @var ClassMetadata|ObjectProphecy
38+
*/
39+
private $metadata;
40+
41+
private $contentDocument;
42+
private $contentDocument2;
43+
private $baseNode;
44+
private $parentRoute;
45+
46+
/**
47+
* @var AutoRouteInterface|ObjectProphecy
48+
*/
49+
private $route;
50+
51+
/**
52+
* @var UriContext|ObjectProphecy
53+
*/
54+
private $uriContext;
55+
56+
/**
57+
* @var SessionInterface|ObjectProphecy
58+
*/
59+
private $phpcrSession;
60+
61+
/**
62+
* @var NodeInterface|ObjectProphecy
63+
*/
64+
private $phpcrRootNode;
65+
private $baseRoutePath;
66+
67+
/**
68+
* @var PhpcrOdmAdapter
69+
*/
70+
private $adapter;
2071

2172
public function setUp()
2273
{
@@ -118,7 +169,8 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $
118169

119170
$this->uriContext->getUri()->willReturn($path);
120171
$this->uriContext->getDefaults()->willReturn([]);
121-
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
172+
$this->uriContext->getSubject()->willReturn($this->contentDocument);
173+
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), 'fr');
122174
$this->assertNotNull($res);
123175
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $res);
124176
$this->assertEquals($expectedName, $res->getName());
@@ -146,8 +198,9 @@ public function testCreateAutoRouteSetDefaults()
146198
'one' => 'k1',
147199
'two' => 'k2',
148200
]);
201+
$this->uriContext->getSubject()->willReturn($this->contentDocument);
149202

150-
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
203+
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), 'fr');
151204
$this->assertNotNull($res);
152205
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $res);
153206
$this->assertEquals('to', $res->getName());
@@ -184,7 +237,8 @@ public function testCreateAutoRouteThrowsExceptionIfItCannotMigrateExistingGener
184237
new \stdClass()
185238
);
186239
$this->uriContext->getUri()->willReturn($uri);
187-
$this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'it');
240+
$this->uriContext->getSubject()->willReturn($this->contentDocument);
241+
$this->adapter->createAutoRoute($this->uriContext->reveal(), 'it');
188242
}
189243

190244
/**
@@ -196,7 +250,8 @@ public function testCreateAutoRouteNonExistingBasePath()
196250
$this->dm->getPhpcrSession()->willReturn($this->phpcrSession);
197251
$this->dm->find(null, $this->baseRoutePath)->willReturn(null);
198252
$this->uriContext->getUri()->willReturn('/asdasd');
199-
$this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
253+
$this->uriContext->getSubject()->willReturn($this->contentDocument);
254+
$this->adapter->createAutoRoute($this->uriContext->reveal(), 'fr');
200255
}
201256

202257
public function testGetRealClassName()

0 commit comments

Comments
 (0)