Yaffs site version 1.1
[yaffs-website] / vendor / symfony-cmf / routing / Tests / Enhancer / FieldPresenceEnhancerTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony CMF package.
5  *
6  * (c) 2011-2015 Symfony CMF
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Cmf\Component\Routing\Tests\Enhancer;
13
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Cmf\Component\Routing\Enhancer\FieldPresenceEnhancer;
16 use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase;
17
18 class FieldPresenceEnhancerTest extends CmfUnitTestCase
19 {
20     /**
21      * @var FieldPresenceEnhancer
22      */
23     private $mapper;
24     private $request;
25
26     public function setUp()
27     {
28         $this->mapper = new FieldPresenceEnhancer('_template', '_controller', 'cmf_content.controller:indexAction');
29
30         $this->request = Request::create('/test');
31     }
32
33     public function testHasTemplate()
34     {
35         $defaults = array('_template' => 'Bundle:Topic:template.html.twig');
36         $expected = array(
37             '_template' => 'Bundle:Topic:template.html.twig',
38             '_controller' => 'cmf_content.controller:indexAction',
39         );
40         $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request));
41     }
42
43     public function testFieldAlreadyThere()
44     {
45         $defaults = array(
46             '_template' => 'Bundle:Topic:template.html.twig',
47             '_controller' => 'custom.controller:indexAction',
48         );
49         $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request));
50     }
51
52     public function testHasNoSourceValue()
53     {
54         $defaults = array('foo' => 'bar');
55         $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request));
56     }
57
58     public function testHasNoSource()
59     {
60         $this->mapper = new FieldPresenceEnhancer(null, '_controller', 'cmf_content.controller:indexAction');
61
62         $defaults = array('foo' => 'bar');
63         $expected = array(
64             'foo' => 'bar',
65             '_controller' => 'cmf_content.controller:indexAction',
66         );
67         $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request));
68     }
69 }