[Theme] Add screenshots to theme configuration

This commit is contained in:
Kamil Kokot 2016-04-20 13:19:30 +02:00
parent 1033cb924b
commit 34f966a746
No known key found for this signature in database
GPG key ID: 7BD76F7054D93C89
2 changed files with 85 additions and 0 deletions

View file

@ -35,6 +35,7 @@ final class ThemeConfiguration implements ConfigurationInterface
$this->addOptionalDescriptionField($rootNodeDefinition);
$this->addOptionalPathField($rootNodeDefinition);
$this->addOptionalParentsList($rootNodeDefinition);
$this->addOptionalScreenshotsList($rootNodeDefinition);
$this->addOptionalAuthorsList($rootNodeDefinition);
return $treeBuilder;
@ -86,6 +87,20 @@ final class ThemeConfiguration implements ConfigurationInterface
;
}
/**
* @param ArrayNodeDefinition $rootNodeDefinition
*/
private function addOptionalScreenshotsList(ArrayNodeDefinition $rootNodeDefinition)
{
$parentsNodeDefinition = $rootNodeDefinition->children()->arrayNode('screenshots');
$parentsNodeDefinition
->requiresAtLeastOneElement()
->performNoDeepMerging()
->prototype('scalar')
->cannotBeEmpty()
;
}
/**
* @param ArrayNodeDefinition $rootNodeDefinition
*/

View file

@ -271,6 +271,76 @@ class ThemeConfigurationTest extends \PHPUnit_Framework_TestCase
);
}
/**
* @test
*/
public function its_screenshots_are_strings()
{
$this->assertConfigurationIsValid(
[
['screenshots' => ['screenshot/krzysztof-krawczyk.jpg', 'screenshot/ryszard-rynkowski.jpg']],
],
'screenshots'
);
}
/**
* @test
*/
public function its_screenshots_are_optional()
{
$this->assertConfigurationIsValid(
[
[/* no screenshots defined */],
],
'screenshots'
);
}
/**
* @test
*/
public function its_screenshots_must_have_at_least_one_element()
{
$this->assertPartialConfigurationIsInvalid(
[
['screenshots' => [/* no elements */]],
],
'screenshots'
);
}
/**
* @test
*/
public function its_screenshots_cannot_be_empty()
{
$this->assertPartialConfigurationIsInvalid(
[
['screenshots' => ['']],
],
'screenshots'
);
}
/**
* @test
*/
public function its_screenshots_replaces_other_screenshots_defined_elsewhere()
{
$this->assertProcessedConfigurationEquals(
[
['screenshots' => ['screenshot/zbigniew-holdys.jpg']],
['screenshots' => ['screenshot/maryla-rodowicz.jpg']],
],
['screenshots' => ['screenshot/maryla-rodowicz.jpg']],
'screenshots'
);
}
/**
* {@inheritdoc}
*/
protected function getConfiguration()
{
return new ThemeConfiguration();