Backup of db before drupal security update
[yaffs-website] / vendor / symfony-cmf / routing / Tests / Enhancer / FieldMapEnhancerTest.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\Mapper;
13
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase;
16 use Symfony\Cmf\Component\Routing\Enhancer\FieldMapEnhancer;
17
18 class FieldMapEnhancerTest extends CmfUnitTestCase
19 {
20     /**
21      * @var Request
22      */
23     private $request;
24
25     /**
26      * @var FieldMapEnhancer
27      */
28     private $enhancer;
29
30     public function setUp()
31     {
32         $this->request = Request::create('/test');
33         $mapping = array('static_pages' => 'cmf_content.controller:indexAction');
34
35         $this->enhancer = new FieldMapEnhancer('type', '_controller', $mapping);
36     }
37
38     public function testFieldFoundInMapping()
39     {
40         $defaults = array('type' => 'static_pages');
41         $expected = array(
42             'type' => 'static_pages',
43             '_controller' => 'cmf_content.controller:indexAction',
44         );
45         $this->assertEquals($expected, $this->enhancer->enhance($defaults, $this->request));
46     }
47
48     public function testFieldAlreadyThere()
49     {
50         $defaults = array(
51             'type' => 'static_pages',
52             '_controller' => 'custom.controller:indexAction',
53         );
54         $this->assertEquals($defaults, $this->enhancer->enhance($defaults, $this->request));
55     }
56
57     public function testNoType()
58     {
59         $defaults = array();
60         $this->assertEquals(array(), $this->enhancer->enhance($defaults, $this->request));
61     }
62
63     public function testNotFoundInMapping()
64     {
65         $defaults = array('type' => 'unknown_route');
66         $this->assertEquals($defaults, $this->enhancer->enhance($defaults, $this->request));
67     }
68 }