resetActiveTheme example

        $function = $theme . '_form_system_theme_settings_alter';
        if (function_exists($function)) {
          $function($form$form_state);
        }
      }

      // Restore the original current theme.       if (isset($default_theme)) {
        $this->themeManager->setActiveTheme($default_active_theme);
      }
      else {
        $this->themeManager->resetActiveTheme();
      }
    }

    return $form;
  }

  /** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form$form_state);

    
$condition_negated->setConfiguration(['theme' => 'test_theme', 'negate' => TRUE]);

    $this->assertEquals(new FormattableMarkup('The current theme is @theme', ['@theme' => 'test_theme'])$condition->summary());
    $this->assertEquals(new FormattableMarkup('The current theme is not @theme', ['@theme' => 'test_theme'])$condition_negated->summary());

    // The expected theme has not been set up yet.     $this->assertFalse($condition->execute());
    $this->assertTrue($condition_negated->execute());

    // Set the expected theme to be used.     $this->config('system.theme')->set('default', 'test_theme')->save();
    \Drupal::theme()->resetActiveTheme();

    $this->assertTrue($condition->execute());
    $this->assertFalse($condition_negated->execute());
  }

}
    $this->assertSession()->elementsCount('xpath', '//link[contains(@href, "' . $base . '/samename.css")]', 1);
    $this->assertSession()->elementsCount('xpath', '//link[contains(@href, "' . $sub . '/samename.css")]', 1);

  }

  /** * Tests that changes to the info file are picked up. */
  public function testChanges() {
    $this->themeInstaller->install(['test_theme']);
    $this->config('system.theme')->set('default', 'test_theme')->save();
    $this->themeManager->resetActiveTheme();

    $active_theme = $this->themeManager->getActiveTheme();
    // Make sure we are not testing the wrong theme.     $this->assertEquals('test_theme', $active_theme->getName());
    $this->assertEquals(['starterkit_theme/base', 'starterkit_theme/messages', 'core/normalize', 'test_theme/global-styling']$active_theme->getLibraries());

    // @see theme_test_system_info_alter()     $this->state->set('theme_test.modify_info_files', TRUE);
    $this->resetAll();
    $active_theme = $this->themeManager->getActiveTheme();
    $this->assertEquals(['starterkit_theme/base', 'starterkit_theme/messages', 'core/normalize', 'test_theme/global-styling', 'core/once']$active_theme->getLibraries());
  }
Home | Imprint | This part of the site doesn't use cookies.