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 #131 from symfony-cmf/handle_missing_basepath
Browse files Browse the repository at this point in the history
throw exception if the base path node does not exist
  • Loading branch information
lsmith77 committed Aug 29, 2014
2 parents 31a7eef + 863d6df commit ab78374
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Adapter/PhpcrOdmAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public function createAutoRoute($uri, $contentDocument, $autoRouteTag)
{
$path = $this->baseRoutePath;
$document = $parentDocument = $this->dm->find(null, $path);
if (null === $parentDocument) {
throw new \RuntimeException(sprintf('The "route_basepath" configuration points to a non-existant path "%s".',
$path
));
}

$segments = preg_split('#/#', $uri, null, PREG_SPLIT_NO_EMPTY);
$headName = array_pop($segments);
foreach ($segments as $segment) {
Expand Down
12 changes: 12 additions & 0 deletions Tests/Unit/Adapter/PhpcrOdmAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $
$this->assertSame($this->contentDocument, $res->getContent());
}

/**
* @expectedException \RuntimeException
* @expectedExceptionMessage configuration points to a non-existant path
*/
public function testCreateAutoRouteNonExistingBasePath()
{
$this->dm->getPhpcrSession()->willReturn($this->phpcrSession);
$this->dm->find(null, $this->baseRoutePath)->willReturn(null);
$this->adapter->createAutoRoute('/foo', $this->contentDocument, 'fr');
}


public function testGetRealClassName()
{
$res = $this->adapter->getRealClassName('Class/Foo');
Expand Down

0 comments on commit ab78374

Please sign in to comment.