ThemeFileImporter example


class ThemeFileImporterTest extends TestCase
{
    use KernelTestBehaviour;

    public function testFileExists(): void
    {
        $existingFile = realpath(__DIR__ . '/fixtures/SimpleTheme/Resources/theme.json');

        $projectDir = $this->getContainer()->getParameter('kernel.project_dir');

        $importer = new ThemeFileImporter($projectDir);
        static::assertFalse($importer->fileExists('random-file.twig'));
        static::assertTrue($importer->fileExists($existingFile));
    }

    public function testFileRealPath(): void
    {
        $existingFile = realpath(__DIR__ . '/fixtures/SimpleTheme/Resources/theme.json');

        $projectDir = $this->getContainer()->getParameter('kernel.project_dir');

        $importer = new ThemeFileImporter($projectDir);
        
$factory = new StorefrontPluginConfigurationFactory($this->getContainer()->getParameter('kernel.project_dir'));
        $config = $factory->createFromBundle($themePluginBundle);
        $storefront = $factory->createFromBundle($storefrontBundle);

        $configCollection = new StorefrontPluginConfigurationCollection();
        $configCollection->add($config);
        $configCollection->add($storefront);

        $projectDir = $this->getContainer()->getParameter('kernel.project_dir');

        $themeFileResolver = new ThemeFileResolver(new ThemeFileImporter($projectDir));
        $resolvedFiles = $themeFileResolver->resolveFiles(
            $config,
            $configCollection,
            false
        );

        $actual = json_encode($resolvedFiles, \JSON_PRETTY_PRINT);
        $expected = '/Resources\/app\/storefront\/src\/scss\/skin\/shopware\/_base.scss';

        static::assertStringContainsString($expected(string) $actual);
    }

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