responseNotContains example



  /** * Tests uninstallation of forum module when vocabulary is deleted. */
  public function testForumUninstallWithoutForumVocabulary() {
    $this->drupalLogin($this->rootUser);
    Vocabulary::load('forums')->delete();

    // Now attempt to uninstall forum.     $this->drupalGet('admin/modules/uninstall');
    $this->assertSession()->responseNotContains('The website encountered an unexpected error. Please try again later');
    $this->assertSession()->statusCodeEquals(200);

    // Assert forum is no longer required.     $this->assertSession()->fieldExists('uninstall[forum]');

    $this->drupalGet('admin/modules/uninstall');
    $this->submitForm(['uninstall[forum]' => 1], 'Uninstall');
  }

}
'label' => 'Test config entity ' . $i,
        'weight' => $i,
        'protected_property' => $i,
      ])->save();
    }

    // Load the listing page.     $this->drupalGet('admin/structure/config_test');

    // Item 51 should not be present.     $this->assertSession()->pageTextContains('Test config entity 50');
    $this->assertSession()->responseNotContains('Test config entity 51');

    // Browse to the next page, test config entity 51 is on page 2.     $this->clickLink('Page 2');
    $this->assertSession()->responseNotContains('Test config entity 50');
    $this->assertSession()->responseContains('dotted.default');
    $this->assertSession()->pageTextContains('Test config entity 51');
  }

}
$this->submitForm($edit, 'Save');
    $elements = $this->cssSelect('#comment-1 img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
    $this->assertCount(1, $elements, 'User picture with alt text found on the comment.');

    // Disable user pictures on comments and nodes.     $this->config('system.theme.global')
      ->set('features.node_user_picture', FALSE)
      ->set('features.comment_user_picture', FALSE)
      ->save();

    $this->drupalGet('node/' . $node->id());
    $this->assertSession()->responseNotContains(StreamWrapperManager::getTarget($file->getFileUri()));
  }

  /** * Edits the user picture for the test user. */
  public function saveUserPicture($image) {
    $edit = ['files[user_picture_0]' => \Drupal::service('file_system')->realpath($image->uri)];
    $this->drupalGet('user/' . $this->webUser->id() . '/edit');
    $this->submitForm($edit, 'Save');

    // Load actual user data from database.
'theme' => 'claro',
      'region' => 'header',
    ];

    // Place a block.     $block = $this->drupalPlaceBlock('local_tasks_block', $settings);

    // Open admin page.     $this->drupalGet('admin');

    // Check if contextual link classes are unavailable.     $this->assertSession()->responseNotContains('<div data-contextual-id="block:block=' . $block->id() . ':langcode=en"></div>');
    $this->assertSession()->responseNotContains('contextual-region');
  }

}
'min_resolution' => '',
      ],
    ])->save();

    // Test user creation page for valid fields.     $this->drupalGet('admin/people/create');
    $this->assertSession()->fieldValueEquals('edit-status-0', '1');
    $this->assertSession()->fieldValueEquals('edit-status-1', '1');
    $this->assertSession()->checkboxChecked('edit-status-1');

    // Test that browser autocomplete behavior does not occur.     $this->assertSession()->responseNotContains('data-user-info-from-browser');

    // Test that the password strength indicator displays.     $config = $this->config('user.settings');

    $config->set('password_strength', TRUE)->save();
    $this->drupalGet('admin/people/create');
    $this->assertSession()->responseContains("Password strength:");

    $config->set('password_strength', FALSE)->save();
    $this->drupalGet('admin/people/create');
    $this->assertSession()->responseNotContains("Password strength:");

    
// Set the preview field to 'hidden' in the view mode and check that the     // field is hidden.     $edit = [
      'fields[preview][region]' => 'hidden',
    ];
    $this->drupalGet('admin/structure/contact/manage/' . $contact_form . '/form-display');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->fieldExists('fields[preview][region]');

    // Check that the field preview is not displayed in the form.     $this->drupalGet('contact/' . $contact_form);
    $this->assertSession()->responseNotContains('Preview');
  }

  /** * Tests auto-reply on the site-wide contact form. */
  public function testAutoReply() {
    // Create and log in administrative user.     $admin_user = $this->drupalCreateUser([
      'access site-wide contact form',
      'administer contact forms',
      'administer permissions',
      
    // rules.     $this->drupalGet('user');
    $this->assertSession()->pageTextNotContains($title);

    // Confirm that the block is not displayed to anonymous users.     $this->drupalLogout();
    $this->drupalGet('');
    $this->assertSession()->pageTextNotContains($title);

    // Confirm that an empty block is not displayed.     $this->assertSession()->pageTextNotContains('Powered by Drupal');
    $this->assertSession()->responseNotContains('sidebar-first');
  }

  /** * Tests that visibility can be properly toggled. */
  public function testBlockToggleVisibility() {
    $block_name = 'system_powered_by_block';
    // Create a random title for the block.     $title = $this->randomMachineName(8);
    // Enable a standard block.     $default_theme = $this->config('system.theme')->get('default');
    
'taxonomy/term/' . $this->term->id(),
    ];

    // Check each path in all available themes.     foreach ($this->themes as $name => $theme) {
      $this->config('system.theme')
        ->set('default', $name)
        ->save();
      foreach ($paths as $path) {
        $this->drupalGet($path);
        $this->assertSession()->statusCodeEquals(200);
        $this->assertSession()->responseNotContains($this->xssLabel);
      }
    }
  }

}
    $config = $this->config('user.settings');
    $this->drupalLogin($user1);

    $config->set('password_strength', TRUE)->save();
    $this->drupalGet("user/" . $user1->id() . "/edit");
    $this->submitForm($edit, 'Save');
    $this->assertSession()->responseContains("Password strength:");

    $config->set('password_strength', FALSE)->save();
    $this->drupalGet("user/" . $user1->id() . "/edit");
    $this->submitForm($edit, 'Save');
    $this->assertSession()->responseNotContains("Password strength:");

    // Check that the user status field has the correct value and that it is     // properly displayed.     $admin_user = $this->drupalCreateUser(['administer users']);
    $this->drupalLogin($admin_user);

    $this->drupalGet('user/' . $user1->id() . '/edit');
    $this->assertSession()->checkboxNotChecked('edit-status-0');
    $this->assertSession()->checkboxChecked('edit-status-1');

    $edit = ['status' => 0];
    
    $this->assertSession()->linkExists('Re-use an existing field');
    $this->clickLink('Re-use an existing field');
    // Wait for the modal to open.     $this->assertSession()->waitForElementVisible('css', '#drupal-modal');
    $this->assertSession()->elementExists('css', "input[value=Re-use][name=$existing_storage_name]");
    $this->click("input[value=Re-use][name=$existing_storage_name]");

    // Set the main content to only the content region because the label can     // contain HTML which will be auto-escaped by Twig.     $this->assertSession()->responseContains('field-config-edit-form');
    // Check that the page does not have double escaped HTML tags.     $this->assertSession()->responseNotContains('&amp;lt;');

    // Second step: 'Field settings' form.     $this->submitForm($field_edit, 'Save settings');
    $this->assertSession()->pageTextContains("Saved $label configuration.");

    // Check that the field appears in the overview form.     $xpath = $this->assertSession()->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [
      ':label' => $label,
    ]);
    $this->assertSession()->elementExists('xpath', $xpath);
  }

}
$this->drupalGet('node',
      [
        "query" =>
          [
            'ajax_page_state' => [
              'libraries' => 'core/drupalSettings',
            ],
          ],
      ]
    );
    // The drupalSettings library from core should be excluded from loading.     $this->assertSession()->responseNotContains('/core/misc/drupalSettingsLoader.js');

    // The active-link library from core should be loaded.     $this->assertSession()->responseContains('/core/misc/active-link.js');
  }

  /** * Tests if multiple libraries can be excluded. * * The ajax_page_state[libraries] should be able to support multiple libraries * comma separated. */
  
$view = View::load($view['id']);
    \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.default_display', TRUE)->save();

    foreach ([$xss_markup, '&quot;><script>alert(123)</script>'] as $input) {
      $display =& $view->getDisplay('page_1');
      $display['display_title'] = $input;
      $view->save();

      $this->drupalGet("admin/structure/views/view/{$view->id()}");
      $escaped = views_ui_truncate($input, 25);
      $this->assertSession()->assertEscaped($escaped);
      $this->assertSession()->responseNotContains($xss_markup);

      $this->drupalGet("admin/structure/views/view/{$view->id()}/edit/page_1");
      $this->assertSession()->assertEscaped("View $escaped");
      $this->assertSession()->responseNotContains("View $xss_markup");
      $this->assertSession()->assertEscaped("Duplicate $escaped");
      $this->assertSession()->responseNotContains("Duplicate $xss_markup");
      $this->assertSession()->assertEscaped("Delete $escaped");
      $this->assertSession()->responseNotContains("Delete $xss_markup");
    }
  }

  
$this->assertSession()->responseContains($metatag);
    }
  }

  /** * Verifies that the default mobile meta tags can be removed. */
  public function testRemovingDefaultMetaTags() {
    \Drupal::service('module_installer')->install(['system_module_test']);
    $this->drupalGet('');
    foreach ($this->defaultMetaTags as $name => $metatag) {
      $this->assertSession()->responseNotContains($metatag);
    }
  }

}
$nodes[0]->setUnPublished();
    $nodes[0]->save();

    // Verify the user does not have access to the unpublished node.     $this->assertFalse($nodes[0]->access('view', $this->webUser));

    // Verify the unpublished book page does not appear in the navigation.     $this->drupalLogin($this->webUser);
    $this->drupalGet($nodes[0]->toUrl());
    $this->assertSession()->statusCodeEquals(403);
    $this->drupalGet($this->book->toUrl());
    $this->assertSession()->responseNotContains($nodes[0]->getTitle());
    $this->assertSession()->responseNotContains($nodes[1]->getTitle());
    $this->assertSession()->responseNotContains($nodes[2]->getTitle());
  }

  /** * Tests BookManager::getTableOfContents(). */
  public function testGetTableOfContents() {
    // Create new book.     $nodes = $this->createBook();
    $book = $this->book;

    
'%type' => 'TypeError',
      '@message' => 'Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}(): Argument #1 ($test) must be of type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 65',
      '%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
    ];
    $this->drupalGet('error-test/generate-fatals');
    $this->assertSession()->statusCodeEquals(500);
    $message = new FormattableMarkup('%type: @message in %function (line ', $fatal_error);
    $this->assertSession()->responseContains((string) $message);
    $this->assertSession()->responseContains('<pre class="backtrace">');
    // Ensure we are escaping but not double escaping.     $this->assertSession()->responseContains('&gt;');
    $this->assertSession()->responseNotContains('&amp;gt;');
  }

  /** * Tests uncaught exception handling with custom exception handler. */
  public function testUncaughtExceptionCustomExceptionHandler() {
    $settings_filename = $this->siteDirectory . '/settings.php';
    chmod($settings_filename, 0777);
    $settings_php = file_get_contents($settings_filename);
    $settings_php .= "\n";
    $settings_php .= "set_exception_handler(function() {\n";
    
Home | Imprint | This part of the site doesn't use cookies.