setScriptFiles example

$config->setStorefrontEntryFilepath($this->getEntryFile($path));
            $config->setIsTheme(true);
            $config->setName($data['name']);
            $config->setAuthor($data['author']);

            if (\array_key_exists('style', $data) && \is_array($data['style'])) {
                $this->resolveStyleFiles($data['style']$basePath$config);
            }

            if (\array_key_exists('script', $data) && \is_array($data['script'])) {
                $fileCollection = FileCollection::createFromArray($data['script']);
                $config->setScriptFiles($this->addBasePathToCollection($fileCollection$basePath));
            }

            if (\array_key_exists('asset', $data)) {
                $config->setAssetPaths($this->addBasePathToArray($data['asset']$basePath));
            }

            if (\array_key_exists('previewMedia', $data)) {
                $config->setPreviewMedia($basePath . \DIRECTORY_SEPARATOR . $data['previewMedia']);
            }

            if (\array_key_exists('config', $data)) {
                
$this->configurationRegistryMock,
            $this->connectionMock
        );

        $this->context = Context::createDefaultContext();
    }

    public function testThemeUninstallWithoutData(): void
    {
        $themeConfig = new StorefrontPluginConfiguration('SimpleTheme');
        $themeConfig->setStyleFiles(new FileCollection());
        $themeConfig->setScriptFiles(new FileCollection());
        $themeConfig->setName('Simple Theme');
        $themeConfig->setIsTheme(true);

        $collection = new StorefrontPluginConfigurationCollection([
            $themeConfig,
        ]);

        $this->configurationRegistryMock->expects(static::once())->method('getConfigurations')->willReturn(
            $collection
        );

        
$this->configurationRegistryMock->expects(static::once())
            ->method('getConfigurations')
            ->willReturn($configs);

        $this->themeLifecycleHandler->handleThemeUninstall($uninstalledConfig, Context::createDefaultContext());
    }

    public function testHandleThemeUninstallWillThrowExceptionIfThemeIsStillInUse(): void
    {
        $uninstalledConfig = $this->configFactory->createFromBundle(new SimpleTheme());
        $uninstalledConfig->setStyleFiles(new FileCollection());
        $uninstalledConfig->setScriptFiles(new FileCollection());

        $configs = new StorefrontPluginConfigurationCollection([
            $this->configFactory->createFromBundle(new Storefront()),
            $uninstalledConfig,
        ]);

        $this->themeLifecycleHandler->handleThemeInstallOrUpdate($uninstalledConfig$configs, Context::createDefaultContext());
        $this->assignThemeToDefaultSalesChannel('SimpleTheme');

        $wasThrown = false;

        
$config,
            $configCollection,
            false
        );

        // Path is still relative         static::assertSame(
            $currentPath,
            $config->getStyleFiles()->first() ? $config->getStyleFiles()->first()->getFilepath() : ''
        );

        $config->setScriptFiles(new FileCollection());
        $config->setStorefrontEntryFilepath(__FILE__);

        (new ThemeFileResolver(new ThemeFileImporter($projectDir)))->resolveFiles(
            $config,
            $configCollection,
            true
        );

        static::assertSame(
            $currentPath,
            $config->getStyleFiles()->first() ? $config->getStyleFiles()->first()->getFilepath() : ''
        );
Home | Imprint | This part of the site doesn't use cookies.