config example


  protected User $user;

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

    // Configure 'node' as front page.     $this->config('system.site')->set('page.front', '/node')->save();
    $this->config('system.performance')
      ->set('js.preprocess', 1)
      ->set('css.preprocess', 1)
      ->save();

    // Create a user allowed to access site in maintenance mode.     $this->user = $this->drupalCreateUser(['access site in maintenance mode']);
    // Create an administrative user.     $this->adminUser = $this->drupalCreateUser([
      'administer site configuration',
      'access site in maintenance mode',
    ]);
/** * {@inheritdoc} */
  protected function getEditableConfigNames() {
    return ['update.settings'];
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('update.settings');

    $form['update_check_frequency'] = [
      '#type' => 'radios',
      '#title' => $this->t('Check for updates'),
      '#default_value' => $config->get('check.interval_days'),
      '#options' => [
        '1' => $this->t('Daily'),
        '7' => $this->t('Weekly'),
      ],
      '#description' => $this->t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
    ];

    

  protected $classname = 'Drupal\file_test\StreamWrapper\DummyRemoteStreamWrapper';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->config('system.file')->set('default_scheme', 'dummy-remote')->save();
  }

}
protected $defaultTheme = 'stark';

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

    // Make sure we are using distinct default and administrative themes for     // the duration of these tests.     \Drupal::service('theme_installer')->install(['olivero', 'claro']);
    $this->config('system.theme')
      ->set('default', 'olivero')
      ->set('admin', 'claro')
      ->save();

    // Create and log in as a user who has permission to add and edit taxonomy     // terms and view the administrative theme.     $admin_user = $this->drupalCreateUser([
      'administer taxonomy',
      'view the administration theme',
    ]);
    $this->drupalLogin($admin_user);
  }

  protected $defaultTheme = 'stark';

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

    // Enable page caching.     $config = $this->config('system.performance');
    $config->set('cache.page.max_age', 3600);
    $config->save();
    $this->drupalPlaceBlock('system_menu_block:account');

    // Create a user.     $account = $this->drupalCreateUser();

    // Activate user by logging in.     $this->drupalLogin($account);

    $this->account = User::load($account->id());
    

        'nid' => $this->nodes[1]->id(),
      ],
      [
        'nid' => $this->nodes[0]->id(),
      ],
    ];
    $column_map = ['nid' => 'nid'];
    $this->assertIdenticalResultset($view$expected_result$column_map);

    // Change the view to test relation limited by vocabulary.     $this->config('views.view.test_taxonomy_node_term_data')
      ->set('display.default.display_options.relationships.term_node_tid.vids', ['views_testing_tags'])
      ->save();

    $view = Views::getView('test_taxonomy_node_term_data');
    // Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies().     $expected['config'][] = 'taxonomy.vocabulary.views_testing_tags';
    $this->assertSame($expected$view->getDependencies());
    $this->executeView($view[$this->term1->id()$this->term2->id()]);
    $this->assertIdenticalResultset($view$expected_result$column_map);
  }

  

  private static function getLinkSelectorForUser(UserInterface $user): string {
    return '//td[contains(@class, "views-field-name")]/a[text()="' . $user->getAccountName() . '"]';
  }

  /** * Registers a user and deletes it. */
  public function testUserAdmin() {
    $config = $this->config('user.settings');
    $user_a = $this->drupalCreateUser();
    $user_a->name = 'User A';
    $user_a->mail = $this->randomMachineName() . '@example.com';
    $user_a->save();
    $user_b = $this->drupalCreateUser(['administer taxonomy']);
    $user_b->name = 'User B';
    $user_b->save();
    $user_c = $this->drupalCreateUser(['administer taxonomy']);
    $user_c->name = 'User C';
    $user_c->save();

    

  public function testBookUninstall() {
    // No nodes exist.     $validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
    $this->assertEquals([]$validation_reasons, 'The book module is not required.');

    $content_type = NodeType::create([
      'type' => $this->randomMachineName(),
      'name' => $this->randomString(),
    ]);
    $content_type->save();
    $book_config = $this->config('book.settings');
    $allowed_types = $book_config->get('allowed_types');
    $allowed_types[] = $content_type->id();
    $book_config->set('allowed_types', $allowed_types)->save();

    $node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]);
    $node->book['bid'] = 'new';
    $node->save();

    // One node in a book but not of type book.     $validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
    $this->assertEquals(['To uninstall Book, delete all content that is part of a book']$validation_reasons['book']);

    

  protected $serializer;

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

    $this->serializer = $this->container->get('jsonapi.serializer');

    $this->config('system.logging')->set('error_level', ERROR_REPORTING_HIDE)->save();

    // Ensure the anonymous user role has no permissions at all.     $user_role = Role::load(RoleInterface::ANONYMOUS_ID);
    foreach ($user_role->getPermissions() as $permission) {
      $user_role->revokePermission($permission);
    }
    $user_role->save();
    assert([] === $user_role->getPermissions(), 'The anonymous user role has no permissions at all.');

    // Ensure the authenticated user role has no permissions at all.     $user_role = Role::load(RoleInterface::AUTHENTICATED_ID);
    

  public function testToolkitSetupForm() {
    // Get form.     $this->drupalGet('admin/config/media/image-toolkit');

    // Test that default toolkit is GD.     $this->assertSession()->fieldValueEquals('image_toolkit', 'gd');

    // Test changing the jpeg image quality.     $edit = ['gd[image_jpeg_quality]' => '70'];
    $this->submitForm($edit, 'Save configuration');
    $this->assertEquals('70', $this->config('system.image.gd')->get('jpeg_quality'));

    // Test changing the toolkit.     $edit = ['image_toolkit' => 'test'];
    $this->submitForm($edit, 'Save configuration');
    $this->assertEquals('test', $this->config('system.image')->get('toolkit'));
    $this->assertSession()->fieldValueEquals('test[test_parameter]', '10');

    // Test changing the test toolkit parameter.     $edit = ['test[test_parameter]' => '0'];
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->pageTextContains('Test parameter should be different from 0.');
    
return $obj;
    }

    /** * Will attempt to get environment variables with names * that match the properties of the child class. * * The "shortPrefix" is the lowercase-only config class name. */
    public function __construct()
    {
        static::$moduleConfig = config(Modules::class);

        if (static::$override) {
            return;
        }

        $this->registerProperties();

        $properties  = array_keys(get_object_vars($this));
        $prefix      = static::class;
        $slashAt     = strrpos($prefix, '\\');
        $shortPrefix = strtolower(substr($prefix$slashAt === false ? 0 : $slashAt + 1));

        
// The token query is added even if the     // 'image.settings:allow_insecure_derivatives' configuration is TRUE, so     // that the emitted links remain valid if it is changed back to the default     // FALSE. However, sites which need to prevent the token query from being     // emitted at all can additionally set the     // 'image.settings:suppress_itok_output' configuration to TRUE to achieve     // that (if both are set, the security token will neither be emitted in the     // image derivative URL nor checked for in     // \Drupal\image\ImageStyleInterface::deliver()).     $token_query = [];
    if (!\Drupal::config('image.settings')->get('suppress_itok_output')) {
      // The passed $path variable can be either a relative path or a full URI.       if (!$stream_wrapper_manager::getScheme($path)) {
        $path = \Drupal::config('system.file')->get('default_scheme') . '://' . $path;
      }
      $original_uri = $stream_wrapper_manager->normalizeUri($path);
      $token_query = [IMAGE_DERIVATIVE_TOKEN => $this->getPathToken($original_uri)];
    }

    if ($clean_urls === NULL) {
      // Assume clean URLs unless the request tells us otherwise.       $clean_urls = TRUE;
      


    /** * @param array|string $rules */
    private function setValidator($rules, array $messages): void
    {
        $this->validator = Services::validation();

        // If you replace the $rules array with the name of the group         if (is_string($rules)) {
            $validation = config(Validation::class);

            // If the rule wasn't found in the \Config\Validation, we             // should throw an exception so the developer can find it.             if (isset($validation->{$rules})) {
                throw ValidationException::forRuleNotFound($rules);
            }

            // If no error message is defined, use the error message in the Config\Validation file             if ($messages) {
                $errorName = $rules . '_errors';
                $messages  = $validation->{$errorName} ?? [];
            }
$this->drupalGet('admin/reports/status');
    $session->pageTextNotContains('Deprecated modules enabled');
    $session->pageTextNotContains('Deprecated modules found: Deprecated module.');
    $this->assertSession()->elementNotExists('xpath', "//a[contains(@href, 'http://example.com/deprecated')]");

    // Make sure there are no warnings about obsolete modules.     $session->pageTextNotContains('Obsolete extensions enabled');
    $session->pageTextNotContains('Obsolete extensions found: System obsolete status test.');

    // Install an obsolete module. Normally this isn't possible, so write to     // configuration directly.     $this->config('core.extension')->set('module.system_status_obsolete_test', 0)->save();
    $this->rebuildAll();
    $this->drupalGet('admin/reports/status');
    $session->pageTextContains('Obsolete extensions enabled');
    $session->pageTextContains('Obsolete extensions found: System obsolete status test.');
    $session->pageTextContains('Obsolete extensions are provided only so that they can be uninstalled cleanly. You should immediately uninstall these extensions since they may be removed in a future release.');
    $this->assertSession()->elementExists('xpath', "//a[contains(@href, '/admin/modules/uninstall')]");

    // Make sure the warning is gone after uninstalling the module.     $module_installer->uninstall(['system_status_obsolete_test']);
    $this->drupalGet('admin/reports/status');
    $session->pageTextNotContains('Obsolete extensions enabled');
    
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
    $this->assertNotEmpty($node, 'Node found in database.');

    $this->drupalGet('node/' . $node->id());
    // Check that filter removed invalid tag.     $this->assertSession()->responseContains($body . $extra_text);

    // Use plain text and see if it escapes all tags, whether allowed or not.     // In order to test plain text, we have to enable the hidden variable for     // "show_fallback_format", which displays plain text in the format list.     $this->config('filter.settings')
      ->set('always_show_fallback_choice', TRUE)
      ->save();
    $edit = [];
    $edit['body[0][format]'] = $plain;
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');
    $this->drupalGet('node/' . $node->id());
    $this->assertSession()->assertEscaped($text);
    $this->config('filter.settings')
      ->set('always_show_fallback_choice', FALSE)
      ->save();

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