final test for configuration refs #265

This commit is contained in:
Julien Fastré 2014-11-04 17:22:56 +01:00
parent e987a891a7
commit 9ec7889595
2 changed files with 39 additions and 1 deletions

View File

@ -29,7 +29,14 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
*/
class ConfigCustomizablesEntitiesTest extends KernelTestCase
{
public function testEmptyConfig()
/**
* Test that the config does work if the option
* chill_custom_fields.customizables_entities IS NOT present
*
* In this case, parameter 'chill_custom_fields.customizables_entities'
* should be an empty array in container
*/
public function testNotPresentInConfig()
{
self::bootKernel(array('environment' => 'test'));
$customizableEntities = static::$kernel->getContainer()
@ -38,4 +45,26 @@ class ConfigCustomizablesEntitiesTest extends KernelTestCase
$this->assertInternalType('array', $customizableEntities);
$this->assertCount(0, $customizableEntities);
}
/**
* Test that the 'chill_custom_fields.customizables_entities' is filled
* correctly with a minimal configuration.
*
* @internal use a custom config environment
*/
public function testNotEmptyConfig()
{
self::bootKernel(array('environment' => 'test_customizable_entities_test_not_empty_config'));
$customizableEntities = static::$kernel->getContainer()
->getParameter('chill_custom_fields.customizables_entities');
$this->assertInternalType('array', $customizableEntities);
$this->assertCount(1, $customizableEntities);
foreach($customizableEntities as $key => $config) {
$this->assertInternalType('array', $config);
$this->assertArrayHasKey('name', $config);
$this->assertArrayHasKey('class', $config);
}
}
}

View File

@ -0,0 +1,9 @@
#required by ConfigCustomizablesEntitiesTest::testNotEmptyConfig
imports:
- { resource: config_test.yml }
chill_custom_fields:
customizables_entities:
- { class: Test\With\A\Dummy\Entity, name: test }