Skip to content

Commit

Permalink
Merge pull request #96 from dmaicher/fix_issue_95
Browse files Browse the repository at this point in the history
fix issue with overwriting default config on default profile
  • Loading branch information
HeahDude authored Aug 29, 2022
2 parents 6642e1c + 948bd5e commit 153e71b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/DependencyInjection/ExerciseHTMLPurifierExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public function load(array $configs, ContainerBuilder $container): void

// Set default serializer cache path, while ensuring a default profile is defined
$configs['html_profiles']['default']['config']['Cache.SerializerPath'] = $configs['default_cache_serializer_path'];
$configs['html_profiles']['default']['config']['Cache.SerializerPermissions'] = $configs['default_cache_serializer_permissions'];

if (!isset($configs['html_profiles']['default']['config']['Cache.SerializerPermissions'])) {
$configs['html_profiles']['default']['config']['Cache.SerializerPermissions'] = $configs['default_cache_serializer_permissions'];
}

$serializerPaths = [];
// Drop when require Symfony > 3.4
Expand Down
24 changes: 24 additions & 0 deletions tests/DependencyInjection/ExerciseHTMLPurifierExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,30 @@ public function testShouldAllowOverridingDefaultConfigurationCacheSerializerPerm
$this->assertRegistryHasProfiles(['default']);
}

public function testShouldAllowOverridingDefaultConfigurationCacheSerializerPermissionsOnDefaultProfile(): void
{
$config = [
'default_cache_serializer_path' => null,
'html_profiles' => [
'default' => [
'config' => [
'AutoFormat.AutoParagraph' => true,
'Cache.SerializerPermissions' => 511,
],
],
],
];

$this->extension->load([$config], $this->container);

$this->assertDefaultConfigDefinition(array_merge($config['html_profiles']['default']['config'], [
'Cache.SerializerPath' => null,
'Cache.SerializerPermissions' => 511,
]));
$this->assertCacheWarmerSerializerArgs([], ['default']);
$this->assertRegistryHasProfiles(['default']);
}

public function testShouldNotDeepMergeOptions(): void
{
$configs = [
Expand Down

0 comments on commit 153e71b

Please sign in to comment.