install example


  public static $testViews = ['test_area_order'];

  /** * {@inheritdoc} */
  protected function setUpFixtures() {
    // Install the themes used for this test.     $this->container->get('theme_installer')->install(['olivero']);

    $this->placeBlock('system_branding_block', [
      'id' => 'id_olivero_branding',
      'theme' => 'olivero',
      'plugin' => 'system_branding_block',
      'weight' => 1,
    ]);

    $this->placeBlock('system_powered_by_block', [
      'id' => 'id_olivero_powered',
      'theme' => 'olivero',
      

  protected ComponentPluginManager $manager;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    if (empty(static::$themes)) {
      throw new \Exception('You need to set the protected static $themes property on your test class, with the first item being the default theme.');
    }
    $this->container->get('theme_installer')->install(static::$themes);
    $this->installConfig('system');

    $system_theme_config = $this->container->get('config.factory')->getEditable('system.theme');
    $system_theme_config
      ->set('default', reset(static::$themes))
      ->save();
    $this->negotiator = new ComponentNegotiator(
      \Drupal::service('theme.manager'),
      \Drupal::service('extension.list.module'),
    );
    $this->manager = \Drupal::service('plugin.manager.sdc');
  }

  protected $allModules;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->themeHandler = $this->container->get('theme_handler');

    $this->container->get('theme_installer')->install(['stable9']);

    $this->installAllModules();
  }

  /** * Installs all core modules. */
  protected function installAllModules() {
    // Enable all core modules.     $all_modules = $this->container->get('extension.list.module')->getList();
    $all_modules = array_filter($all_modulesfunction D$module) {
      
$this->uninstallModule('node');
    $this->assertNull($this->getStorage('view')->load('frontpage'), 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.');
  }

  /** * Installs a module. * * @param string $module * The module name. */
  protected function installModule($module) {
    $this->container->get('module_installer')->install([$module]);
    $this->container = \Drupal::getContainer();
  }

  /** * Uninstalls a module. * * @param string $module * The module name. */
  protected function uninstallModule($module) {
    $this->container->get('module_installer')->uninstall([$module]);
    
$admin = $this->drupalCreateUser(['administer themes']);
    $this->drupalLogin($admin);
  }

  /** * Tests that submission handler works correctly. * * @dataProvider providerTestFormSettingsSubmissionHandler */
  public function testFormSettingsSubmissionHandler($theme) {

    \Drupal::service('theme_installer')->install([$theme]);

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet("admin/appearance/settings/$theme");

    // Add a new managed file.     $file = current($this->getTestFiles('image'));
    $image_file_path = \Drupal::service('file_system')->realpath($file->uri);
    $page->attachFileToField('files[custom_logo]', $image_file_path);
    $assert_session->waitForButton('custom_logo_remove_button');

    
if (!$index) {
        $this->assertInstanceOf(TermInterface::class$row->_relationship_entities['parent']);
        $this->assertEquals($this->term2->id()$row->_relationship_entities['parent']->id());
        $this->assertEquals($this->term2->id()$row->taxonomy_term_field_data_taxonomy_term__parent_tid);
      }
      $this->assertInstanceOf(NodeInterface::class$row->_relationship_entities['nid']);
      $this->assertEquals($this->nodes[$index]->id()$row->_relationship_entities['nid']->id());
    }

    // Test node fields are available through relationship.     \Drupal::service('module_installer')->install(['views_ui']);
    $this->drupalLogin($this->createUser(['administer views']));
    $this->drupalGet('admin/structure/views/view/test_taxonomy_term_relationship');
    $this->click('#views-add-field');
    $this->assertSession()->pageTextContains('Body');
  }

}
$translation_after->setString('updated_translation')->save();
  }

  /** * Tests getDefaultConfigLangcode(). */
  public function testGetDefaultConfigLangcode() {
    // Install the Language module's configuration so we can use the     // module_installer service.     $this->installConfig(['language']);
    $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'Before installing a module the locale config manager can not access the shipped configuration.');
    \Drupal::service('module_installer')->install(['locale_test_translate']);
    $this->assertEquals('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'After installing a module the locale config manager can get the shipped configuration langcode.');

    $simple_config = \Drupal::configFactory()->getEditable('locale_test_translate.simple_config_extra');
    $simple_config->set('foo', 'bar')->save();
    $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode($simple_config->getName()), 'Simple config created through the API is not treated as shipped configuration.');

    $block = Block::create([
      'id' => 'test_default_config',
      'theme' => 'stark',
      'status' => TRUE,
      'region' => 'content',
      

  protected $defaultTheme = 'stark';

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

    // Use the big_pipe_test_theme theme.     $this->container->get('theme_installer')->install(['big_pipe_test_theme']);
    $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'big_pipe_test_theme')->save();
  }

  /** * Ensure BigPipe works despite inline JS containing the string "</body>". * * @see https://www.drupal.org/node/2678662 */
  public function testMultipleClosingBodies_2678662() {
    $this->assertTrue($this->container->get('module_installer')->install(['render_placeholder_message_test'], TRUE), 'Installed modules.');

    
$this->assertTrue($context['is_syncing'], 'Inside a custom step \Drupal::isConfigSyncing() returns TRUE');
    $this->assertFalse(\Drupal::isConfigSyncing(), 'After an valid custom step \Drupal::isConfigSyncing() returns FALSE');
  }

  /** * Tests that uninstall a theme in config import correctly imports all config. */
  public function testUninstallThemeIncrementsCount(): void {
    $theme_installer = $this->container->get('theme_installer');
    // Install our theme.     $theme = 'test_basetheme';
    $theme_installer->install([$theme]);

    $this->assertTrue($this->container->get('theme_handler')->themeExists($theme));

    $sync = $this->container->get('config.storage.sync');

    // Update 2 pieces of config in sync.     $systemSiteName = 'system.site';
    $system = $sync->read($systemSiteName);
    $system['name'] = 'Foo';
    $sync->write($systemSiteName$system);

    
/** * Tests the Update module storage is cleared correctly. */
  public function testUpdateStorage() {
    // Setting values in both key stores, then installing the module and     // testing if these key values are cleared.     $keyvalue_update = $this->container->get('keyvalue.expirable')->get('update');
    $keyvalue_update->set('key', 'some value');
    $keyvalue_update_available_release = $this->container->get('keyvalue.expirable')->get('update_available_release');
    $keyvalue_update_available_release->set('key', 'some value');
    $this->container->get('module_installer')->install(['help']);
    $this->assertNull($keyvalue_update->get('key'));
    $this->assertNull($keyvalue_update_available_release->get('key'));

    // Setting new values in both key stores, then uninstalling the module and     // testing if these new key values are cleared.     $keyvalue_update->set('another_key', 'some value');
    $keyvalue_update_available_release->set('another_key', 'some value');
    $this->container->get('module_installer')->uninstall(['help']);
    $this->assertNull($keyvalue_update->get('another_key'));
    $this->assertNull($keyvalue_update_available_release->get('another_key'));
  }

}

  public function testNodePath() {
    $view = $this->initViewWithRequest($this->nodes[0]->toUrl()->toString());

    $expected = implode(',', [$this->term1->id()$this->term2->id()]);
    $this->assertEquals($expected$view->argument['tid']->getDefaultArgument());
    $view->destroy();
  }

  public function testNodePathWithViewSelection() {
    // Change the term entity reference field to use a view as selection plugin.     \Drupal::service('module_installer')->install(['entity_reference_test']);

    $field_name = 'field_' . $this->vocabulary->id();
    $field = FieldConfig::loadByName('node', 'article', $field_name);
    $field->setSetting('handler', 'views');
    $field->setSetting('handler_settings', [
      'view' => [
        'view_name' => 'test_entity_reference',
        'display_name' => 'entity_reference_1',
      ],
    ]);
    $field->save();

    
/** * Tests that all Core help topics can be rendered and have good syntax. */
  public function testHelpTopics() {
    $this->drupalLogin($this->rootUser);

    // Enable all modules and themes, so that all routes mentioned in topics     // will be defined.     $module_directories = $this->listDirectories('module');
    $modules_to_install = array_keys($module_directories);
    \Drupal::service('module_installer')->install($modules_to_install);
    $theme_directories = $this->listDirectories('theme');
    \Drupal::service('theme_installer')->install(array_keys($theme_directories));

    $directories = $module_directories + $theme_directories +
      $this->listDirectories('profile');
    $directories['core'] = \Drupal::root() . '/core/help_topics';
    $directories['bad_help_topics'] = \Drupal::service('extension.list.module')->getPath('help_topics_test') . '/bad_help_topics/syntax/';

    // Filter out directories outside of core. If you want to run this test     // on a contrib/custom module, remove the next line.     $directories = array_filter($directoriesfunction D$directory) {
      

  protected function setUp($import_test_views = TRUE, $modules = []): void {
    parent::setUp($import_test_views$modules);
    $this->enableViewsTestModule();
    $user = $this->createUser([], NULL, TRUE);
    $this->drupalLogin($user);

    // Set the Stark theme and use the default templates from views module.     /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = \Drupal::service('theme_installer');
    $theme_installer->install(['stark']);
    $this->config('system.theme')->set('default', 'stark')->save();
  }

  /** * Tests the view with the text. */
  public function testDuplicateText() {
    $output = $this->drupalGet('admin/content');
    $this->assertEquals(1, substr_count($output, 'No content available.'), 'Only one message should be present');
  }

}
$this->assertSession()->fieldExists('entity_bundle[bundles][article]');
    $this->assertSession()->fieldExists('entity_bundle[bundles][page]');
    $this->submitForm(['entity_bundle[bundles][page]' => 'page', 'entity_bundle[bundles][article]' => 'article'], 'Submit');
    // @see \Drupal\condition_test\FormController::submitForm()     $this->assertSession()->pageTextContains('Bundle: page');
    $this->assertSession()->pageTextContains('Bundle: article');
    $this->assertSession()->pageTextContains('Executed successfully.');

    $this->assertSession()->pageTextContains('The current theme is stark');
    /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = $this->container->get('theme_installer');
    $theme_installer->install(['olivero']);
    $this->drupalGet('condition_test');
    $this->submitForm(['current_theme[theme]' => 'olivero', 'current_theme[negate]' => TRUE], 'Submit');
    $this->assertSession()->pageTextContains('The current theme is not olivero');
  }

}
// Ensure visibility remains correct after cached paged load.     $this->drupalGet('user');
    $contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
    $this->assertNotEmpty($contextualLinks);
  }

  /** * Tests clicking contextual links. */
  public function testContextualLinksClick() {
    $this->container->get('module_installer')->install(['contextual_test']);
    // Test clicking contextual link without toolbar.     $this->drupalGet('user');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->clickContextualLink('#block-branding', 'Test Link');
    $this->assertSession()->pageTextContains('Everything is contextual!');

    // Test click a contextual link that uses ajax.     $this->drupalGet('user');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $current_page_string = 'NOT_RELOADED_IF_ON_PAGE';
    $this->getSession()->executeScript('document.body.appendChild(document.createTextNode("' . $current_page_string . '"));');

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