4 * This file is part of the Symfony CMF package.
6 * (c) 2011-2015 Symfony CMF
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Cmf\Component\Routing\Tests\Mapper;
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase;
16 use Symfony\Cmf\Component\Routing\Enhancer\FieldMapEnhancer;
18 class FieldMapEnhancerTest extends CmfUnitTestCase
26 * @var FieldMapEnhancer
30 public function setUp()
32 $this->request = Request::create('/test');
33 $mapping = array('static_pages' => 'cmf_content.controller:indexAction');
35 $this->enhancer = new FieldMapEnhancer('type', '_controller', $mapping);
38 public function testFieldFoundInMapping()
40 $defaults = array('type' => 'static_pages');
42 'type' => 'static_pages',
43 '_controller' => 'cmf_content.controller:indexAction',
45 $this->assertEquals($expected, $this->enhancer->enhance($defaults, $this->request));
48 public function testFieldAlreadyThere()
51 'type' => 'static_pages',
52 '_controller' => 'custom.controller:indexAction',
54 $this->assertEquals($defaults, $this->enhancer->enhance($defaults, $this->request));
57 public function testNoType()
60 $this->assertEquals(array(), $this->enhancer->enhance($defaults, $this->request));
63 public function testNotFoundInMapping()
65 $defaults = array('type' => 'unknown_route');
66 $this->assertEquals($defaults, $this->enhancer->enhance($defaults, $this->request));