ThemeAssetPackage example

use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

/** * @internal */
class ThemeAssetPackageTest extends TestCase
{
    public function testEmptyStack(): void
    {
        $asset = new ThemeAssetPackage(['http://localhost']new EmptyVersionStrategy()new RequestStack()new MD5ThemePathBuilder());

        static::assertSame('http://localhost/all.js', $asset->getUrl('/all.js'));
    }

    public function testAdminRequest(): void
    {
        $request = new Request();
        $stack = new RequestStack();
        $stack->push($request);

        $asset = new ThemeAssetPackage(['http://localhost']new EmptyVersionStrategy()$stacknew MD5ThemePathBuilder());

        
/** * @dataProvider urlCases */
    public function testGetUrl(string $inputUrl, ?Request $request, string $expectedUrl): void
    {
        $requestStack = new RequestStack();

        if ($request instanceof Request) {
            $requestStack->push($request);
        }

        $themeAssetPackage = new ThemeAssetPackage(
            ['http://localhost'],
            new StaticVersionStrategy('v1'),
            $requestStack,
            new MD5ThemePathBuilder()
        );

        $actual = $themeAssetPackage->getUrl($inputUrl);

        static::assertSame($expectedUrl$actual);
    }

    
Home | Imprint | This part of the site doesn't use cookies.