statusMessageNotContains example

          $edit = [
            "{$field_name}[0][uri]" => 'http://www.example.com',
          ];
          $this->submitForm($edit, 'Save');
          $this->assertSession()->statusMessageContains('Link text field is required if there is URL input.', 'error');

          // Verify that the link text is not required, if the URL is empty.           $edit = [
            "{$field_name}[0][uri]" => '',
          ];
          $this->submitForm($edit, 'Save');
          $this->assertSession()->statusMessageNotContains('Link text field is required.');

          // Verify that a URL and link text meets requirements.           $this->drupalGet('entity_test/add');
          $edit = [
            "{$field_name}[0][uri]" => 'http://www.example.com',
            "{$field_name}[0][title]" => 'Example',
          ];
          $this->submitForm($edit, 'Save');
          $this->assertSession()->statusMessageNotContains('Link text field is required.');
        }
      }
    }
// Test that the form saves with the default values.     $this->drupalGet('admin/config/search/pages');
    $this->submitForm([], 'Save configuration');
    $this->assertSession()->statusMessageContains('The configuration options have been saved.', 'status');

    // Test that the form does not save with an invalid word length.     $edit = [
      'minimum_word_size' => $this->randomMachineName(3),
    ];
    $this->drupalGet('admin/config/search/pages');
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->statusMessageNotContains('The configuration options have been saved.');
    $this->assertSession()->statusMessageContains('Minimum word length to index must be a number.', 'error');

    // Test logging setting. It should be off by default.     $text = $this->randomMachineName(5);
    $this->drupalGet('search/node');
    $this->submitForm(['keys' => $text], 'Search');
    $this->drupalGet('admin/reports/dblog');
    $this->assertSession()->linkNotExists('Searched Content for ' . $text . '.', 'Search was not logged');

    // Turn on logging.     $edit = ['logging' => TRUE];
    
 'Save');
    $node = $this->getNodeByTitle('moderated content');

    // Add a pending revision with the same alias.     $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()->fieldValueEquals('path[0][alias]', '/moderated-content');
    $this->submitForm([
      'title[0][value]' => 'pending revision',
      'path[0][alias]' => '/moderated-content',
      'moderation_state[0][state]' => 'draft',
    ], 'Save');
    $this->assertSession()->statusMessageNotContains('You can only change the URL alias for the published version of this content.');

    // Create some moderated content with no path alias.     $this->drupalGet('node/add/moderated');
    $this->assertSession()->fieldValueEquals('path[0][alias]', '');
    $this->submitForm([
      'title[0][value]' => 'moderated content 2',
      'path[0][alias]' => '',
      'moderation_state[0][state]' => 'published',
    ], 'Save');
    $node = $this->getNodeByTitle('moderated content 2');

    
    $edit = [
      'title[0][value]' => "Test $index.3 IT",
      'moderation_state[0][state]' => 'published',
    ];
    $this->submitForm($edit, 'Save (this translation)');
    $entity = $this->storage->loadUnchanged($id);
    $this->assertTrue($entity->hasTranslation('it'));
    $it_revision = $this->loadRevisionTranslation($entity, 'it');
    $this->assertTrue($it_revision->hasTranslation('it'));
    $this->drupalGet($overview_url);
    $this->assertSession()->linkByHrefExists($it_delete_href);
    $this->assertSession()->statusMessageNotContains($warning);
    $this->drupalGet($this->getEditUrl($it_revision));
    $this->assertSession()->buttonExists('Delete translation');

    // Create an English draft and verify the published translation was     // preserved.     $this->drupalLogin($this->editor);
    $en_revision = $this->loadRevisionTranslation($entity, 'en');
    $this->drupalGet($this->getEditUrl($en_revision));
    $edit = [
      'title[0][value]' => "Test $index.4 EN",
      'moderation_state[0][state]' => 'draft',
    ];
$this->assertSession()->statusMessageContains('Please enter some keywords', 'error');
    $this->drupalGet('search/user');
    $this->submitForm([], 'Search');
    $this->assertSession()->statusMessageContains('Please enter some keywords', 'error');

    // Make sure the "Please enter some keywords" message is NOT displayed if     // you use "or" words or phrases in Advanced Search.     $this->drupalGet('search/node');
    $this->submitForm([
      'or' => $this->randomMachineName() . ' ' . $this->randomMachineName(),
    ], 'edit-submit--2');
    $this->assertSession()->statusMessageNotContains('Please enter some keywords');
    $this->drupalGet('search/node');
    $this->submitForm([
      'phrase' => '"' . $this->randomMachineName() . '" "' . $this->randomMachineName() . '"',
    ], 'edit-submit--2');
    $this->assertSession()->statusMessageNotContains('Please enter some keywords');

    // Verify that if you search for a too-short keyword, you get the right     // message, and that if after that you search for a longer keyword, you     // do not still see the message.     $this->drupalGet('search/node');
    $this->submitForm(['keys' => $this->randomMachineName(1)], 'Search');
    
    $edit = [
      'prefix[fr]' => 'french',
    ];
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->fieldValueEquals("prefix[fr]", 'french');

    // Check that the prefix can be removed.     $edit = [
      'prefix[fr]' => '',
    ];
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->statusMessageNotContains('The prefix may only be left blank for the selected detection fallback language.');

    // Change default negotiation language.     $this->config('language.negotiation')->set('selected_langcode', 'fr')->save();
    // Check that the prefix of a language that is not the negotiation one     // cannot be changed to empty string.     $edit = [
      'prefix[en]' => '',
    ];
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->statusMessageContains('The prefix may only be left blank for the selected detection fallback language.', 'error');

    
/** * Verifies that a warning message is displayed for experimental modules. */
  public function testExperimentalHelp() {
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/help/experimental_module_test');
    $this->assertSession()->statusMessageContains('This module is experimental.', 'warning');

    // Regular modules should not display the message.     $this->drupalGet('admin/help/help_page_test');
    $this->assertSession()->statusMessageNotContains('This module is experimental.');

    // Ensure the actual help page is displayed to avoid a false positive.     $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains('online documentation for the Help Page Test module');
  }

}
    $this->assertEquals(
      $this->getUrl(),
      Url::fromRoute('search.view_' . $entity_id[]['query' => ['keys' => ''], 'absolute' => TRUE])->toString(),
      'Redirected to correct URL.'
    );

    // Test that after entering a too-short keyword in the form, you can then     // search again with a longer keyword. First test using the block form.     $this->drupalGet('node');
    $this->submitForm(['keys' => $this->randomMachineName(1)], 'Search');
    $this->assertSession()->statusMessageContains('You must include at least one keyword to match in the content', 'warning');
    $this->assertSession()->statusMessageNotContains('Please enter some keywords');
    $this->submitForm(['keys' => $this->randomMachineName()], 'Search', 'search-block-form');
    $this->assertSession()->statusMessageNotContains('You must include at least one keyword to match in the content');

    // Same test again, using the search page form for the second search this     // time.     $this->drupalGet('node');
    $this->submitForm(['keys' => $this->randomMachineName(1)], 'Search');
    $this->submitForm(['keys' => $this->randomMachineName()], 'Search', 'search-form');
    $this->assertSession()->statusMessageNotContains('You must include at least one keyword to match in the content');

    // Edit the block configuration so that it searches users instead of nodes,
 while (--$num_runs && $remaining);
    $this->assertNotEmpty($num_runs);
    $this->assertEmpty($remaining);

    // Visit the Search settings page and verify it says 100% indexed.     $this->drupalGet('admin/config/search/pages');
    $this->assertSession()->pageTextContains('100% of the site has been indexed');
    // Search and verify there is no warning.     $this->drupalGet('search/help');
    $this->submitForm(['keys' => 'not-a-word-english'], 'Search');
    $this->assertSearchResultsCount(1);
    $this->assertSession()->statusMessageNotContains('Help search is not fully indexed');
  }

  /** * Tests help topic search. */
  public function testHelpSearch() {
    $german = \Drupal::languageManager()->getLanguage('de');
    $session = $this->assertSession();

    // Verify that when we search in English for a word that is only in     // English text, we find the topic. Note that these "words" are provided
/** * Tests the URL filter settings form is properly validated. */
  public function testUrlFilterAdmin() {
    // The form does not save with an invalid filter URL length.     $edit = [
      'filters[filter_url][settings][filter_url_length]' => $this->randomMachineName(4),
    ];
    $this->drupalGet('admin/config/content/formats/manage/basic_html');
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->statusMessageNotContains('The text format Basic HTML has been updated.');
  }

  /** * Tests whether filter tips page is not HTML escaped. */
  public function testFilterTipHtmlEscape() {
    $this->drupalLogin($this->adminUser);
    global $base_url;

    $site_name_with_markup = 'Filter test <script>alert(\'here\');</script> site name';
    $this->config('system.site')->set('name', $site_name_with_markup)->save();

    
$instance->setSetting('alt_field_required', 0);
    $instance->setSetting('title_field_required', 0);
    $instance->save();

    $edit = [
      'title[0][value]' => $this->randomMachineName(),
    ];
    $this->drupalGet('node/add/article');
    $this->submitForm($edit, 'Save');

    $this->assertSession()->statusMessageNotContains('Alternative text field is required.');
    $this->assertSession()->statusMessageNotContains('Title field is required.');

    $instance->setSetting('required', 0);
    $instance->setSetting('alt_field_required', 1);
    $instance->setSetting('title_field_required', 1);
    $instance->save();

    $edit = [
      'title[0][value]' => $this->randomMachineName(),
    ];
    $this->drupalGet('node/add/article');
    
$warning_message = 'The block ' . $block->id() . ' was assigned to the invalid region invalid_region and has been disabled.';

    // Clearing the cache should disable the test block placed in the invalid region.     $this->drupalGet('admin/config/development/performance');
    $this->submitForm([], 'Clear all caches');
    $this->assertSession()->statusMessageContains($warning_message, 'warning');

    // Clear the cache to check if the warning message is not triggered.     $this->drupalGet('admin/config/development/performance');
    $this->submitForm([], 'Clear all caches');
    $this->assertSession()->statusMessageNotContains($warning_message, 'warning');

    // Place disabled test block in the invalid region of the default theme.     \Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
    $block = Block::load($block->id());

    // Clear the cache to check if the warning message is not triggered.     $this->drupalGet('admin/config/development/performance');
    $this->submitForm([], 'Clear all caches');
    $this->assertSession()->statusMessageNotContains($warning_message, 'warning');
  }

}
    $this->assertSession()->statusMessageContains('My Status Message');
    $this->assertSession()->statusMessageContains('My Error Message');
    $this->assertSession()->statusMessageContains('My Warning Message');
    // Test partial match.     $this->assertSession()->statusMessageContains('My Status');
    // Test with second arg.     $this->assertSession()->statusMessageContains('My Status Message', 'status');
    $this->assertSession()->statusMessageContains('My Error Message', 'error');
    $this->assertSession()->statusMessageContains('My Warning Message', 'warning');

    // Test WebAssert::statusMessageNotContains().     $this->assertSession()->statusMessageNotContains('My Status Message is fake');
    $this->assertSession()->statusMessageNotContains('My Status Message is fake', 'status');
    $this->assertSession()->statusMessageNotContains('My Error Message', 'status');
    $this->assertSession()->statusMessageNotContains('My Status Message', 'error');

    // Check that special characters get handled correctly.     $this->assertSession()->statusMessageContains('This has " in the middle');
    $this->assertSession()->statusMessageContains('This has \' in the middle');
    $this->assertSession()->statusMessageContains('<em>This<span>markup will be</span> escaped</em>');
    $this->assertSession()->statusMessageContains('Peaches & cream');
    $this->assertSession()->statusMessageNotContains('Peaches &amp; cream');

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