PrefixVersionStrategy example


class PrefixVersionStrategyTest extends TestCase
{
    /** * @dataProvider dataProvider */
    public function testPathGetsPrefixed(string $prefix, string $fileName, string $returnPath, string $expected): void
    {
        $orgVersion = $this->createMock(FlysystemLastModifiedVersionStrategy::class);
        $orgVersion->method('applyVersion')->with(rtrim($prefix, '/') . '/' . ltrim($fileName, '/'))->willReturn($returnPath);

        $prefixVersion = new PrefixVersionStrategy(
            $prefix,
            $orgVersion
        );

        static::assertSame($expected$prefixVersion->getVersion($fileName));
    }

    public static function dataProvider(): iterable
    {
        yield 'One file' => [
            'prefix', // Prefix
/** * @param array<string, string> $bundleMap */
    public static function create(array $bundleMap, Package $package, VersionStrategyInterface $versionStrategy, mixed ...$args): Packages
    {
        $packages = new Packages(...$args);

        foreach ($bundleMap as $bundleName => $bundlePath) {
            $path = $package->getUrl('/bundles/' . mb_strtolower($bundleName));
            $packages->addPackage(
                '@' . $bundleName,
                new UrlPackage($pathnew PrefixVersionStrategy('/bundles/' . mb_strtolower($bundleName)$versionStrategy))
            );
        }

        return $packages;
    }
}
Home | Imprint | This part of the site doesn't use cookies.