InMemoryFilesystemAdapter example

class UrlGeneratorTest extends TestCase
{
    public function testAbsoluteMediaUrl(): void
    {
        $mediaEntity = new MediaEntity();
        $mediaEntity->assign(
            [
                'id' => Uuid::randomHex(),
                'fileName' => 'file.jpg',
            ]
        );
        $urlGenerator = new UrlGenerator(new FilenamePathnameStrategy()new Filesystem(new InMemoryFilesystemAdapter()['public_url' => 'http://localhost:8000']));
        static::assertSame(
            'http://localhost:8000/media/d0/b3/24/file.jpg',
            $urlGenerator->getAbsoluteMediaUrl($mediaEntity)
        );
    }

    public function testMediaUrlWithEmptyRequest(): void
    {
        $mediaEntity = new MediaEntity();
        $mediaEntity->assign(
            [
                
/** * @internal */
class StaticFileConfigLoaderTest extends TestCase
{
    public function testFileNotExisting(): void
    {
        static::expectException(\RuntimeException::class);
        static::expectExceptionMessage('Cannot find theme configuration. Did you run bin/console theme:dump');

        $fs = new Filesystem(new InMemoryFilesystemAdapter());
        $s = new StaticFileConfigLoader($fs);
        $s->load(Uuid::randomHex(), Context::createDefaultContext());
    }

    public function testBuild(): void
    {
        $id = Uuid::randomHex();

        $fs = new Filesystem(new InMemoryFilesystemAdapter());
        $fs->write('theme-config/' . $id . '.json', (string) file_get_contents(__DIR__ . '/../fixtures/ConfigLoader/theme-config.json'));

        
private ThemeCompiler $themeCompiler;

    private string $mockSalesChannelId;

    protected function setUp(): void
    {
        $mockThemeFileResolver = $this->createMock(ThemeFileResolver::class);
        $eventDispatcher = $this->createMock(EventDispatcher::class);

        // Avoid filesystem operations         $mockFilesystem = new Filesystem(new InMemoryFilesystemAdapter());

        $this->mockSalesChannelId = '98432def39fc4624b33213a56b8c944d';

        $this->themeCompiler = new ThemeCompiler(
            $mockFilesystem,
            $mockFilesystem,
            $mockThemeFileResolver,
            true,
            $eventDispatcher,
            $this->createMock(ThemeFileImporter::class),
            ['theme' => new UrlPackage(['http://localhost']new EmptyVersionStrategy())],
            
class UrlGeneratorTest extends TestCase
{
    public function testAbsoluteMediaUrl(): void
    {
        $mediaEntity = new MediaEntity();
        $mediaEntity->assign(
            [
                'id' => Uuid::randomHex(),
                'fileName' => 'file.jpg',
            ]
        );
        $urlGenerator = new UrlGenerator(new FilenamePathnameStrategy()new Filesystem(new InMemoryFilesystemAdapter()['public_url' => 'http://localhost:8000']));
        static::assertSame(
            'http://localhost:8000/media/d0/b3/24/file.jpg',
            $urlGenerator->getAbsoluteMediaUrl($mediaEntity)
        );
    }

    public function testMediaUrlWithEmptyRequest(): void
    {
        $mediaEntity = new MediaEntity();
        $mediaEntity->assign(
            [
                

        ksort($manifest);
        $bundle = new Administration();

        $kernel = $this->createMock(KernelInterface::class);
        $kernel
            ->method('getBundle')
            ->with('AdministrationBundle')
            ->willReturn($bundle);

        $filesystem = $this->createMock(FilesystemOperator::class);
        $privateFilesystem = new Filesystem(new InMemoryFilesystemAdapter());
        $assetService = new AssetService(
            $filesystem,
            $privateFilesystem,
            $kernel,
            new StaticKernelPluginLoader($this->createMock(ClassLoader::class)),
            $this->createMock(CacheInvalidator::class),
            $this->createMock(AbstractAppLoader::class),
            new ParameterBag(['shopware.filesystem.asset.type' => 's3'])
        );

        $privateFilesystem->write('asset-manifest.json', (string) json_encode(['administration' => $manifest], \JSON_PRETTY_PRINT));

        

class StaticFileAvailableThemeProviderTest extends TestCase
{
    public function testFileNotExisting(): void
    {
        static::expectException(\RuntimeException::class);
        static::expectExceptionMessage('Cannot find theme configuration. Did you run bin/console theme:dump');

        $fs = new Filesystem(new InMemoryFilesystemAdapter());
        $s = new StaticFileAvailableThemeProvider($fs);
        $s->load(Context::createDefaultContext(), false);
    }

    public function testFileExists(): void
    {
        $fs = new Filesystem(new InMemoryFilesystemAdapter());
        $fs->write(StaticFileAvailableThemeProvider::THEME_INDEX, json_encode(['test' => 'test'], \JSON_THROW_ON_ERROR));

        $s = new StaticFileAvailableThemeProvider($fs);
        static::assertSame(['test' => 'test']$s->load(Context::createDefaultContext(), false));
    }
Home | Imprint | This part of the site doesn't use cookies.