X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony-cmf%2Frouting%2FTests%2FEnhancer%2FRouteContentEnhancerTest.php;fp=vendor%2Fsymfony-cmf%2Frouting%2FTests%2FEnhancer%2FRouteContentEnhancerTest.php;h=b5b1273d965a71dd7278335682a7b39b7a83231d;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/symfony-cmf/routing/Tests/Enhancer/RouteContentEnhancerTest.php b/vendor/symfony-cmf/routing/Tests/Enhancer/RouteContentEnhancerTest.php new file mode 100644 index 000000000..b5b1273d9 --- /dev/null +++ b/vendor/symfony-cmf/routing/Tests/Enhancer/RouteContentEnhancerTest.php @@ -0,0 +1,85 @@ +document = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Enhancer\RouteObject', + array('getContent', 'getRouteDefaults', 'getUrl')); + + $this->mapper = new RouteContentEnhancer(RouteObjectInterface::ROUTE_OBJECT, '_content'); + + $this->request = Request::create('/test'); + } + + public function testContent() + { + $targetDocument = new TargetDocument(); + $this->document->expects($this->once()) + ->method('getContent') + ->will($this->returnValue($targetDocument)); + + $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->document); + $expected = array(RouteObjectInterface::ROUTE_OBJECT => $this->document, '_content' => $targetDocument); + + $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request)); + } + + public function testFieldAlreadyThere() + { + $this->document->expects($this->never()) + ->method('getContent') + ; + + $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->document, '_content' => 'foo'); + + $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); + } + + public function testNoContent() + { + $this->document->expects($this->once()) + ->method('getContent') + ->will($this->returnValue(null)); + + $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->document); + $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); + } + + public function testNoCmfRoute() + { + $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->buildMock('Symfony\Component\Routing\Route')); + $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); + } +} + +class TargetDocument +{ +} + +class UnknownDocument +{ +}