mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Theme] Add screenshots to theme configuration
This commit is contained in:
parent
1033cb924b
commit
34f966a746
2 changed files with 85 additions and 0 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue