Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,10 @@ private function addAssetMapperSection(ArrayNodeDefinition $rootNode, callable $
->end()
->scalarNode('importmap_polyfill')
->info('The importmap name that will be used to load the polyfill. Set to false to disable.')
->validate()
->ifTrue()
->thenInvalid('Invalid "importmap_polyfill" value. Must be either an importmap name or false.')
->end()
->defaultValue('es-module-shims')
->end()
->arrayNode('importmap_script_attributes')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,42 @@ public function testAssetMapperCanBeEnabled()
$this->assertEquals($defaultConfig, $config['asset_mapper']);
}

/**
* @dataProvider provideImportmapPolyfillTests
*/
public function testAssetMapperPolyfillValue(mixed $polyfillValue, bool $isValid, mixed $expected)
{
$processor = new Processor();
$configuration = new Configuration(true);

if (!$isValid) {
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage($expected);
}

$config = $processor->processConfiguration($configuration, [[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'asset_mapper' => null === $polyfillValue ? [] : [
'importmap_polyfill' => $polyfillValue,
],
]]);

if ($isValid) {
$this->assertEquals($expected, $config['asset_mapper']['importmap_polyfill']);
}
}

public static function provideImportmapPolyfillTests()
{
yield [true, false, 'Must be either an importmap name or false.'];
yield [null, true, 'es-module-shims'];
yield ['es-module-shims', true, 'es-module-shims'];
yield ['foo', true, 'foo'];
yield [false, true, false];
}

/**
* @dataProvider provideValidAssetsPackageNameConfigurationTests
*/
Expand Down