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\Enhancer;
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Cmf\Component\Routing\Enhancer\FieldPresenceEnhancer;
16 use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase;
18 class FieldPresenceEnhancerTest extends CmfUnitTestCase
21 * @var FieldPresenceEnhancer
26 public function setUp()
28 $this->mapper = new FieldPresenceEnhancer('_template', '_controller', 'cmf_content.controller:indexAction');
30 $this->request = Request::create('/test');
33 public function testHasTemplate()
35 $defaults = array('_template' => 'Bundle:Topic:template.html.twig');
37 '_template' => 'Bundle:Topic:template.html.twig',
38 '_controller' => 'cmf_content.controller:indexAction',
40 $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request));
43 public function testFieldAlreadyThere()
46 '_template' => 'Bundle:Topic:template.html.twig',
47 '_controller' => 'custom.controller:indexAction',
49 $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request));
52 public function testHasNoSourceValue()
54 $defaults = array('foo' => 'bar');
55 $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request));
58 public function testHasNoSource()
60 $this->mapper = new FieldPresenceEnhancer(null, '_controller', 'cmf_content.controller:indexAction');
62 $defaults = array('foo' => 'bar');
65 '_controller' => 'cmf_content.controller:indexAction',
67 $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request));