refreshInfo example

$this->assertSession()->pageTextContains('The Experimental test theme has been installed.');

    // Setting it as the default should not ask for another confirmation.     $this->cssSelect('a[title="Set Experimental test as default theme"]')[0]->click();
    $this->assertSession()->pageTextNotContains('Experimental themes are provided for testing purposes only. Use at your own risk.');
    $this->assertSession()->pageTextContains('Experimental test is now the default theme.');
    $this->assertSession()->pageTextNotContains(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION));
    $this->assertSession()->responseContains(sprintf('Experimental test %s (default theme, administration theme, experimental theme)', \Drupal::VERSION));

    // Uninstall the theme.     $this->config('system.theme')->set('default', 'test_theme')->save();
    \Drupal::service('theme_handler')->refreshInfo();
    \Drupal::service('theme_installer')->uninstall(['experimental_theme_test']);

    // Reinstall the same experimental theme, but this time immediately set it     // as the default. This should again trigger a confirmation form with an     // experimental warning.     $this->drupalGet('admin/appearance');
    $this->cssSelect('a[title="Install Experimental test as default theme"]')[0]->click();
    $this->assertSession()->pageTextContains('Experimental themes are provided for testing purposes only. Use at your own risk.');

    // Test enabling a theme that is not itself experimental, but that depends     // on an experimental module.
        // 'translations' stream wrapper is provided by Interface Translation         // module and is later used to import translations.         \Drupal::service('stream_wrapper_manager')->register();

        // Update the theme registry to include it.         \Drupal::service('theme.registry')->reset();

        // Modules can alter theme info, so refresh theme data.         // @todo ThemeHandler cannot be injected into ModuleHandler, since that         // causes a circular service dependency.         // @see https://www.drupal.org/node/2208429         \Drupal::service('theme_handler')->refreshInfo();

        // Allow the module to perform install tasks.         $this->moduleHandler->invoke($module, 'install', [$sync_status]);

        // Record the fact that it was installed.         \Drupal::logger('system')->info('%module module installed.', ['%module' => $module]);
      }
    }

    // If any modules were newly installed, invoke hook_modules_installed().     if (!empty($modules_installed)) {
      

  public function installThemeThatTriggersWarning($theme) {
    $theme_installer = \Drupal::service('theme_installer');
    $theme_installer->install([$theme]);
    $this->config('system.theme')->set('default', $theme)->save();
    $theme_installer->install(['stark']);
    $this->config('system.theme')->set('admin', 'stark')->save();
    \Drupal::service('theme_handler')->refreshInfo();
  }

  /** * Test the ckeditor_stylesheets warning in the filter UI. * * @dataProvider providerTestWarningFilterUI */
  public function testWarningFilterUi($theme$expected_warning) {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();
    $this->addNewTextFormat($page$assert_session);
    
// Use distinct default and administrative themes for this test.     /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
    $theme_handler = $this->container->get('theme_handler');
    /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = $this->container->get('theme_installer');
    $theme_installer->install(['claro']);
    $this->container->get('config.factory')
      ->getEditable('system.theme')
      ->set('admin', 'claro')
      ->set('default', 'stable')
      ->save();
    $theme_handler->refreshInfo();
    // Check that the page has been served with the default theme.     $this->drupalGet('test_page_display_200');
    $this->assertSession()->responseNotContains('core/themes/claro/css/base/elements.css');

    $view = $this->config('views.view.test_page_display');
    $view->set('display.page_3.display_options.use_admin_theme', TRUE)->save();
    $this->container->get('router.builder')->rebuild();

    // Check that the page was served with the administrative theme.     $this->drupalGet('test_page_display_200');
    $this->assertSession()->responseContains('core/themes/claro/css/base/elements.css');
  }
Home | Imprint | This part of the site doesn't use cookies.