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 #211 from symfony-cmf/next_try_remove_parameter
Browse files Browse the repository at this point in the history
Next try remove parameter
  • Loading branch information
ElectricMaxxx authored Aug 16, 2017
2 parents 394d142 + 27e5ad1 commit 776f2f7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"php": "^5.6|^7.0",
"symfony/framework-bundle": "^2.8|^3.0",
"symfony-cmf/routing-auto": "2.0.0-RC2",
"symfony-cmf/routing-auto": "^2.0.0-RC5",
"symfony-cmf/routing-bundle": "^1.2.0|^2.0",
"aferrandini/urlizer": "1.0.*",
"phpdocumentor/reflection-docblock": "^3.1, !=3.2.0"
Expand Down
3 changes: 2 additions & 1 deletion src/Adapter/PhpcrOdmAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ public function removeAutoRoute(AutoRouteInterface $autoRoute)
/**
* {@inheritdoc}
*/
public function createAutoRoute(UriContext $uriContext, $contentDocument, $locale)
public function createAutoRoute(UriContext $uriContext, $locale)
{
$basePath = $this->baseRoutePath;
$contentDocument = $uriContext->getSubject();
$document = $parentDocument = $this->dm->find(null, $basePath);

if (null === $parentDocument) {
Expand Down
67 changes: 61 additions & 6 deletions tests/Unit/Adapter/PhpcrOdmAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,63 @@

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

use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
use PHPCR\NodeInterface;
use PHPCR\SessionInterface;
use Prophecy\Prophecy\ObjectProphecy;
use Symfony\Cmf\Bundle\RoutingAutoBundle\Adapter\PhpcrOdmAdapter;
use Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface;
use Symfony\Cmf\Component\RoutingAuto\UriContext;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;

class PhpcrOdmAdapterTest extends \PHPUnit_Framework_TestCase
{
protected $dm;
protected $baseRoutePath;
/**
* @var DocumentManager|ObjectProphecy
*/
private $dm;

/**
* @var ClassMetadataFactory|ObjectProphecy
*/
private $metadataFactory;

/**
* @var ClassMetadata|ObjectProphecy
*/
private $metadata;

private $contentDocument;
private $contentDocument2;
private $baseNode;
private $parentRoute;

/**
* @var AutoRouteInterface|ObjectProphecy
*/
private $route;

/**
* @var UriContext|ObjectProphecy
*/
private $uriContext;

/**
* @var SessionInterface|ObjectProphecy
*/
private $phpcrSession;

/**
* @var NodeInterface|ObjectProphecy
*/
private $phpcrRootNode;
private $baseRoutePath;

/**
* @var PhpcrOdmAdapter
*/
private $adapter;

public function setUp()
{
Expand Down Expand Up @@ -118,7 +169,8 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $

$this->uriContext->getUri()->willReturn($path);
$this->uriContext->getDefaults()->willReturn([]);
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
$this->uriContext->getSubject()->willReturn($this->contentDocument);
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), 'fr');
$this->assertNotNull($res);
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $res);
$this->assertEquals($expectedName, $res->getName());
Expand Down Expand Up @@ -146,8 +198,9 @@ public function testCreateAutoRouteSetDefaults()
'one' => 'k1',
'two' => 'k2',
]);
$this->uriContext->getSubject()->willReturn($this->contentDocument);

$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), 'fr');
$this->assertNotNull($res);
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $res);
$this->assertEquals('to', $res->getName());
Expand Down Expand Up @@ -184,7 +237,8 @@ public function testCreateAutoRouteThrowsExceptionIfItCannotMigrateExistingGener
new \stdClass()
);
$this->uriContext->getUri()->willReturn($uri);
$this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'it');
$this->uriContext->getSubject()->willReturn($this->contentDocument);
$this->adapter->createAutoRoute($this->uriContext->reveal(), 'it');
}

/**
Expand All @@ -196,7 +250,8 @@ public function testCreateAutoRouteNonExistingBasePath()
$this->dm->getPhpcrSession()->willReturn($this->phpcrSession);
$this->dm->find(null, $this->baseRoutePath)->willReturn(null);
$this->uriContext->getUri()->willReturn('/asdasd');
$this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
$this->uriContext->getSubject()->willReturn($this->contentDocument);
$this->adapter->createAutoRoute($this->uriContext->reveal(), 'fr');
}

public function testGetRealClassName()
Expand Down

0 comments on commit 776f2f7

Please sign in to comment.