X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony-cmf%2Frouting%2FTests%2FEnhancer%2FFieldByClassEnhancerTest.php;fp=vendor%2Fsymfony-cmf%2Frouting%2FTests%2FEnhancer%2FFieldByClassEnhancerTest.php;h=fcc56a1bf594ef0910d6aa0757ed972a46d23ae2;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/vendor/symfony-cmf/routing/Tests/Enhancer/FieldByClassEnhancerTest.php b/vendor/symfony-cmf/routing/Tests/Enhancer/FieldByClassEnhancerTest.php new file mode 100644 index 000000000..fcc56a1bf --- /dev/null +++ b/vendor/symfony-cmf/routing/Tests/Enhancer/FieldByClassEnhancerTest.php @@ -0,0 +1,69 @@ +document = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Enhancer\RouteObject'); + + $mapping = array('Symfony\Cmf\Component\Routing\Tests\Enhancer\RouteObject' => 'cmf_content.controller:indexAction'); + + $this->mapper = new FieldByClassEnhancer('_content', '_controller', $mapping); + + $this->request = Request::create('/test'); + } + + public function testClassFoundInMapping() + { + // this is the mock, thus a child class to make sure we properly check with instanceof + $defaults = array('_content' => $this->document); + $expected = array( + '_content' => $this->document, + '_controller' => 'cmf_content.controller:indexAction', + ); + $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request)); + } + + public function testFieldAlreadyThere() + { + $defaults = array( + '_content' => $this->document, + '_controller' => 'custom.controller:indexAction', + ); + $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); + } + + public function testClassNotFoundInMapping() + { + $defaults = array('_content' => $this); + $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); + } + + public function testNoClass() + { + $defaults = array('foo' => 'bar'); + $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); + } +}