upgrade menuComposer according to #179 - #217

This commit is contained in:
2014-10-06 23:18:56 +02:00
parent e9925a6dd7
commit 96fada19ef
6 changed files with 195 additions and 23 deletions

View File

@@ -0,0 +1,68 @@
<?php
namespace CL\Chill\MainBundle\Tests\Services;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Routing\RouteCollection;
/**
* This class provide functional test for MenuComposer
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class MenuComposer extends KernelTestCase
{
/**
*
* @var \Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader;
*/
private $loader;
/**
*
* @var \CL\Chill\MainBundle\DependencyInjection\Services\MenuComposer;
*/
private $menuComposer;
public function setUp()
{
self::bootKernel();
$this->loader = static::$kernel->getContainer()
->get('routing.loader');
$this->menuComposer = static::$kernel->getContainer()
->get('chill_main.menu_composer');
}
public function testMenuComposer()
{
$collection = new RouteCollection();
$collection->add($this->loader->load(__DIR__.'dummy_menu_composer.yml', 'yaml'));
$routes = $this->menuComposer->getRoutesFor('dummy0');
$this->assertInternalType('array', $routes);
$this->assertCount(2, $routes);
//check that the keys are sorted
$orders = array_keys($routes);
foreach ($orders as $key => $order){
if (array_key_exists($key + 1, $orders)) {
$this->assertGreaterThan($order, $orders[$key + 1],
'Failing to assert that routes are ordered');
}
}
$this->assertSame(array(
50 => array(
'key' => 'chill_main_dummy_0',
'label' => 'test0',
),
51 => array(
'key' => 'chill_main_dummy_1',
'label' => 'test1',
'helper'=> 'great helper'
)
), $routes);
}
}

View File

@@ -0,0 +1,21 @@
chill_main_dummy_0:
pattern: /dummy
defaults: { _controller: CLChillMainBundle:Default:index }
options:
menus:
dummy0:
order: 50
label: 'test0'
dummy1:
order: 50
label: test dummy 1
chill_main_dummy_1:
pattern: /dummy1
defaults: { _controller: CLChillMainBundle:Default:index }
options:
menus:
dummy0:
order: 50
label: 'test1'
helper: 'great helper'