Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html/c12park/web/core/tests/Drupal/KernelTests/Core/Theme/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/html/c12park/web/core/tests/Drupal/KernelTests/Core/Theme/ConfigImportThemeInstallTest.php

<?php

declare(strict_types=1);

namespace Drupal\KernelTests\Core\Theme;

use Drupal\Core\Config\ConfigImporterException;
use Drupal\KernelTests\KernelTestBase;

/**
 * Tests installing and uninstalling of themes via configuration import.
 *
 * @group Extension
 */
class ConfigImportThemeInstallTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['system'];

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->installConfig(['system']);
  }

  /**
   * Tests config imports that install and uninstall a theme with dependencies.
   */
  public function testConfigImportWithThemeWithModuleDependencies(): void {
    $this->container->get('module_installer')->install(['test_module_required_by_theme', 'test_another_module_required_by_theme']);
    $this->container->get('theme_installer')->install(['test_theme_depending_on_modules']);
    $this->assertTrue($this->container->get('theme_handler')->themeExists('test_theme_depending_on_modules'), 'test_theme_depending_on_modules theme installed');

    $sync = $this->container->get('config.storage.sync');
    $this->copyConfig($this->container->get('config.storage'), $sync);
    $extensions = $sync->read('core.extension');
    // Remove one of the modules the theme depends on.
    unset($extensions['module']['test_module_required_by_theme']);
    $sync->write('core.extension', $extensions);

    try {
      $this->configImporter()->validate();
      $this->fail('ConfigImporterException not thrown; an invalid import was not stopped due to missing dependencies.');
    }
    catch (ConfigImporterException $e) {
      $error_message = 'Unable to uninstall the <em class="placeholder">Test Module Required by Theme</em> module because: Required by the theme: Test Theme Depending on Modules.';
      $this->assertStringContainsString($error_message, $e->getMessage(), 'There were errors validating the config synchronization.');
      $error_log = $this->configImporter->getErrors();
      $this->assertSame($error_message, (string) $error_log[0]);
    }

    // Remove the other module and the theme.
    unset($extensions['module']['test_another_module_required_by_theme']);
    unset($extensions['theme']['test_theme_depending_on_modules']);
    $sync->write('core.extension', $extensions);
    $this->configImporter()->import();

    $this->assertFalse($this->container->get('theme_handler')->themeExists('test_theme_depending_on_modules'), 'test_theme_depending_on_modules theme uninstalled by configuration import');

    // Try installing a theme with dependencies via config import.
    $extensions['theme']['test_theme_depending_on_modules'] = 0;
    $extensions['module']['test_another_module_required_by_theme'] = 0;
    $sync->write('core.extension', $extensions);
    try {
      $this->configImporter()->validate();
      $this->fail('ConfigImporterException not thrown; an invalid import was not stopped due to missing dependencies.');
    }
    catch (ConfigImporterException $e) {
      $error_message = 'Unable to install the <em class="placeholder">Test Theme Depending on Modules</em> theme since it requires the <em class="placeholder">Test Module Required by Theme</em> module.';
      $this->assertStringContainsString($error_message, $e->getMessage(), 'There were errors validating the config synchronization.');
      $error_log = $this->configImporter->getErrors();
      $this->assertSame($error_message, (string) $error_log[0]);
    }

    $extensions['module']['test_module_required_by_theme'] = 0;
    $sync->write('core.extension', $extensions);
    $this->configImporter()->import();
    $this->assertTrue($this->container->get('theme_handler')->themeExists('test_theme_depending_on_modules'), 'test_theme_depending_on_modules theme installed');
  }

}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net