Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html1/bbp/web/core/modules/system/tests/src/Functional/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/html1/bbp/web/core/modules/system/tests/src/Functional/Theme/ToolbarClaroOverridesTest.php

<?php

namespace Drupal\Tests\system\Functional\Theme;

use Drupal\Tests\BrowserTestBase;

/**
 * Tests the loading of Claro assets on a non-Claro default theme.
 *
 * @group Theme
 */
class ToolbarClaroOverridesTest extends BrowserTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['toolbar', 'test_page_test', 'shortcut', 'node'];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * The theme installer used in this test for enabling themes.
   *
   * @var \Drupal\Core\Extension\ThemeInstallerInterface
   */
  protected $themeInstaller;

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();

    $this->themeInstaller = $this->container->get('theme_installer');
    $this->themeManager = $this->container->get('theme.manager');
    $this->themeInstaller->install(['claro']);

    // Create user with sufficient permissions to have the shortcut toolbar menu
    // be available.
    $this->drupalLogin($this->drupalCreateUser([
      'access toolbar',
      'access shortcuts',
      'administer shortcuts',
      'access content overview',
    ]));
  }

  /**
   * Confirm Claro assets load on a non-Claro default theme.
   */
  public function testClaroAssets() {
    $default_stylesheets = [
      'core/modules/toolbar/css/toolbar.module.css',
      'core/modules/toolbar/css/toolbar.menu.css',
      'core/modules/toolbar/css/toolbar.theme.css',
      'core/modules/toolbar/css/toolbar.icons.theme.css',
    ];

    $claro_stylesheets = [
      'core/themes/claro/css/components/toolbar.module.css',
      'core/themes/claro/css/state/toolbar.menu.css',
      'core/themes/claro/css/theme/toolbar.theme.css',
      'core/themes/claro/css/theme/toolbar.icons.theme.css',
    ];

    $this->config('system.theme')->set('admin', 'stark')->save();

    $this->drupalGet('test-page');
    $this->assertSession()->statusCodeEquals(200);

    $admin_theme = \Drupal::configFactory()->get('system.theme')->get('admin');
    $default_theme = \Drupal::configFactory()->get('system.theme')->get('default');
    $this->assertEquals('stark', $admin_theme);
    $this->assertEquals('stark', $default_theme);

    $head = $this->getSession()->getPage()->find('css', 'head')->getHtml();

    // Confirm that Claro stylesheets are not loading, and the ones they would
    // override were Claro enabled are still loading.
    $stylesheet_positions = [];
    foreach ($default_stylesheets as $stylesheet) {
      $this->assertStringContainsString($stylesheet, $head);
      $stylesheet_positions[] = strpos($head, $stylesheet);
    }
    $sorted_stylesheet_positions = $stylesheet_positions;
    sort($sorted_stylesheet_positions);
    $this->assertEquals($sorted_stylesheet_positions, $stylesheet_positions);

    foreach ($claro_stylesheets as $stylesheet) {
      $this->assertStringNotContainsString($stylesheet, $head);
    }

    // Confirm toolbar is not processed by claro_preprocess_toolbar().
    $this->assertFalse($this->getSession()->getPage()->find('css', '#toolbar-administration')->hasAttribute('data-drupal-claro-processed-toolbar'));

    // Confirm menu--toolbar.html.twig is not loaded from Claro.
    $this->assertFalse($this->getSession()->getPage()->find('css', '.toolbar-menu')->hasClass('claro-toolbar-menu'));
    $this->assertFalse($this->getSession()->getPage()->find('css', '.toolbar')->hasClass('claro-toolbar'));

    $this->config('system.theme')->set('admin', 'claro')->save();
    $this->drupalGet('test-page');
    $this->assertSession()->statusCodeEquals(200);

    $admin_theme = \Drupal::configFactory()->get('system.theme')->get('admin');
    $default_theme = \Drupal::configFactory()->get('system.theme')->get('default');
    $this->assertEquals('claro', $admin_theme);
    $this->assertEquals('stark', $default_theme);

    $head = $this->getSession()->getPage()->find('css', 'head')->getHtml();

    // Confirm that Claro stylesheets are loading, and the ones they override
    // are not loading.
    $stylesheet_positions = [];
    foreach ($claro_stylesheets as $stylesheet) {
      $this->assertStringContainsString($stylesheet, $head);
      $stylesheet_positions[] = strpos($head, $stylesheet);
    }
    $sorted_stylesheet_positions = $stylesheet_positions;
    sort($sorted_stylesheet_positions);
    $this->assertEquals($sorted_stylesheet_positions, $stylesheet_positions);

    foreach ($default_stylesheets as $stylesheet) {
      $this->assertStringNotContainsString($stylesheet, $head);
    }

    // Confirm toolbar is processed by claro_preprocess_toolbar().
    $this->assertTrue($this->getSession()->getPage()->find('css', '#toolbar-administration')->hasAttribute('data-drupal-claro-processed-toolbar'));

    // Confirm toolbar templates are loaded from Claro.
    $this->assertTrue($this->getSession()->getPage()->find('css', '.toolbar')->hasClass('claro-toolbar'));
    $this->assertTrue($this->getSession()->getPage()->find('css', '.toolbar-menu')->hasClass('claro-toolbar-menu'));
  }

}

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