PublicAssetsPathResolver example

'npm:@hotwired/stimulus@^1.2.3',
            [
                'package' => '@hotwired/stimulus',
                'registry' => 'npm',
                'version' => '^1.2.3',
            ],
        ];
    }

    private function createImportMapManager(array $dirs, string $rootDir, string $publicPrefix = '/assets/', string $publicDirName = 'public'): ImportMapManager
    {
        $pathResolver = new PublicAssetsPathResolver($rootDir$publicPrefix$publicDirName);

        $mapper = $this->createAssetMapper($pathResolver$dirs$rootDir);
        $this->packageResolver = $this->createMock(PackageResolverInterface::class);
        $this->httpClient = $this->createMock(HttpClientInterface::class);

        return new ImportMapManager(
            $mapper,
            $pathResolver,
            $rootDir.'/importmap.php',
            $rootDir.'/assets/vendor',
            $this->packageResolver,
            


namespace Symfony\Component\AssetMapper\Tests\Path;

use PHPUnit\Framework\TestCase;
use Symfony\Component\AssetMapper\Path\PublicAssetsPathResolver;

class PublicAssetsPathResolverTest extends TestCase
{
    public function testResolvePublicPath()
    {
        $resolver = new PublicAssetsPathResolver(
            '/projectRootDir/',
            '/assets-prefix/',
            'publicDirName',
        );
        $this->assertSame('/assets-prefix/', $resolver->resolvePublicPath(''));
        $this->assertSame('/assets-prefix/foo/bar', $resolver->resolvePublicPath('/foo/bar'));
        $this->assertSame('/assets-prefix/foo/bar', $resolver->resolvePublicPath('foo/bar'));

        $resolver = new PublicAssetsPathResolver(
            '/projectRootDir/',
            '/assets-prefix', // The trailing slash should be added automatically
Home | Imprint | This part of the site doesn't use cookies.