refs #265 add a first test + consistency of parameters

This commit is contained in:
Julien Fastré 2014-11-04 17:03:15 +01:00
parent b914229c11
commit b826d8e132
4 changed files with 50 additions and 5 deletions

View File

@ -26,10 +26,11 @@ class ChillCustomFieldsExtension extends Extension
$loader->load('services.yml'); $loader->load('services.yml');
//add at least a blank array at 'customizable_entities' options //add at least a blank array at 'customizable_entities' options
$customizable_entities = (isset($config['customizables_entities']) //$customizable_entities = (isset($config['customizables_entities'])
&& count($config['customizables_entities']) > 0) // && $config['customizables_entities'] !== FALSE)
? $config['customizables_entities'] : array(); // ? $config['customizables_entities'] : array();
$container->setParameter('chill_custom_fields.customizable_entities', $customizable_entities); $container->setParameter('chill_custom_fields.customizables_entities',
$config['customizables_entities']);
} }
} }

View File

@ -22,10 +22,13 @@ class Configuration implements ConfigurationInterface
$classInfo = "The class which may receive custom fields"; $classInfo = "The class which may receive custom fields";
$nameInfo = "The name which will appears in the user interface. May be translatable"; $nameInfo = "The name which will appears in the user interface. May be translatable";
$customizableEntitiesInfo = "A list of customizable entities";
$rootNode $rootNode
->children() ->children()
->arrayNode('customizables_entities') ->arrayNode('customizables_entities')
->info($customizableEntitiesInfo)
->defaultValue(array())
->prototype('array') ->prototype('array')
->children() ->children()
->scalarNode('class')->isRequired()->info($classInfo)->end() ->scalarNode('class')->isRequired()->info($classInfo)->end()

View File

@ -18,7 +18,7 @@ services:
chill.custom_field.custom_fields_group_type: chill.custom_field.custom_fields_group_type:
class: Chill\CustomFieldsBundle\Form\CustomFieldsGroupType class: Chill\CustomFieldsBundle\Form\CustomFieldsGroupType
arguments: arguments:
- %chill_custom_fields.customizable_entities% - %chill_custom_fields.customizables_entities%
- "@translator" - "@translator"
tags: tags:
- { name: 'form.type', alias: 'custom_fields_group' } - { name: 'form.type', alias: 'custom_fields_group' }

View File

@ -0,0 +1,41 @@
<?php
/*
*
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\CustomFieldsBundle\Tests\Config;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* Test the option Customizables_entities
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class ConfigCustomizablesEntitiesTest extends KernelTestCase
{
public function testEmptyConfig()
{
self::bootKernel(array('environment' => 'test'));
$customizableEntities = static::$kernel->getContainer()
->getParameter('chill_custom_fields.customizables_entities');
$this->assertInternalType('array', $customizableEntities);
$this->assertCount(0, $customizableEntities);
}
}