This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from benglass/render_menu_absolute_path
Use absolutizePath to support absolute and relative paths.
- Loading branch information
Showing
2 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony CMF package. | ||
* | ||
* (c) 2011-2013 Symfony CMF | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
|
||
namespace Symfony\Cmf\Bundle\MenuBundle\Tests\Unit\Provider; | ||
|
||
use Symfony\Cmf\Bundle\MenuBundle\Provider\PhpcrMenuProvider; | ||
|
||
class PhpcrMenuProviderTest extends \PHPUnit_Framework_Testcase | ||
{ | ||
/** | ||
* @dataProvider getMenuTests | ||
*/ | ||
public function testGet($menuRoot, $name, $expectedPath) | ||
{ | ||
$objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); | ||
$objectManager->expects($this->once()) | ||
->method('find') | ||
->with($this->equalTo(null), $this->equalTo($expectedPath)) | ||
->will($this->returnValue($this->getMock('Knp\Menu\NodeInterface'))); | ||
|
||
$managerRegistry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); | ||
$managerRegistry->expects($this->once()) | ||
->method('getManager') | ||
->will($this->returnValue($objectManager)); | ||
|
||
$factory = $this->getMock('Knp\Menu\FactoryInterface'); | ||
$factory->expects($this->once()) | ||
->method('createFromNode') | ||
->will($this->returnValue($this->getMock('Knp\Menu\ItemInterface'))); | ||
|
||
$provider = new PhpcrMenuProvider( | ||
$factory, | ||
$managerRegistry, | ||
$menuRoot | ||
); | ||
|
||
$provider->setRequest($this->getMock('Symfony\Component\HttpFoundation\Request')); | ||
|
||
$provider->get($name); | ||
} | ||
|
||
/** | ||
* @dataProvider getMenuTests | ||
*/ | ||
public function testHas($menuRoot, $name, $expectedPath) | ||
{ | ||
$objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); | ||
$objectManager->expects($this->once()) | ||
->method('find') | ||
->with($this->equalTo(null), $this->equalTo($expectedPath)) | ||
->will($this->returnValue($this->getMock('Knp\Menu\NodeInterface'))); | ||
|
||
$managerRegistry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); | ||
$managerRegistry->expects($this->once()) | ||
->method('getManager') | ||
->will($this->returnValue($objectManager)); | ||
|
||
$provider = new PhpcrMenuProvider( | ||
$this->getMock('Knp\Menu\FactoryInterface'), | ||
$managerRegistry, | ||
$menuRoot | ||
); | ||
|
||
$provider->has($name); | ||
} | ||
|
||
public function getMenuTests() | ||
{ | ||
return array( | ||
array('/test/menu', 'foo', '/test/menu/foo'), | ||
array('/test/menu', '/another/menu/path', '/another/menu/path'), | ||
); | ||
} | ||
|
||
} |