fieldValueNotEquals example


    $this->drupalGet('admin/config/regional/language/add');
    $this->submitForm($edit, 'Add language');

    // Overridden string for language-negotiation should not exist in the form.     $this->drupalGet('admin/config/regional/language/detection/url');

    // The language-negotiation form should be found.     $this->assertSession()->pageTextContains('Path prefix configuration');

    // The English override should not be found.     $this->assertSession()->fieldValueNotEquals('prefix[en]', $overridden_value_en);

    // Now check the Spanish version of the page for the same thing.     $this->drupalGet($overridden_value_es . '/admin/config/regional/language/detection/url');

    // The language-negotiation form should be found.     $this->assertSession()->pageTextContains('Path prefix configuration');

    // The Spanish override should not be found.     $this->assertSession()->fieldValueNotEquals('prefix[es]', $overridden_value_es);

  }

}
// Verify that #element_validate handlers can make form elements     // inaccessible, but values persist.     $edit = [
      'name' => 'element_validate_access',
    ];
    $this->submitForm($edit, 'Save');
    $this->assertSession()->fieldNotExists('name');
    $this->assertSession()->pageTextContains('Name value: element_validate_access');

    // Verify that value for inaccessible form element persists.     $this->submitForm([], 'Save');
    $this->assertSession()->fieldValueNotEquals('name', 'Form element was hidden.');
    $this->assertSession()->pageTextContains('Name value: element_validate_access');

    // Verify that #validate handlers don't run if the CSRF token is invalid.     $this->drupalLogin($this->drupalCreateUser());
    $this->drupalGet('form-test/validate');
    // $this->assertSession()->fieldExists() does not recognize hidden fields,     // which breaks $this->submitForm() if we try to change the value of a     // hidden field such as form_token.     $this->assertSession()
      ->elementExists('css', 'input[name="form_token"]')
      ->setValue('invalid_token');
    


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

    // Check that the export is empty on load.     $this->drupalGet('admin/config/development/configuration/single/export');
    $this->assertSession()->fieldValueEquals('export', '');

    // Check that the export is filled when selecting a config name.     $page->selectFieldOption('config_name', 'system.site');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->fieldValueNotEquals('export', '');

    // Check that the export is emptied again when selecting a config type.     $page->selectFieldOption('config_type', 'Action');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->fieldValueEquals('export', '');
  }

}
    if ($entity !== NULL) {
      $this->drupalGet('comment/reply/entity_test/' . $entity->id() . '/comment');
    }

    // Determine the visibility of subject form field.     $display_repository = $this->container->get('entity_display.repository');
    if ($display_repository->getFormDisplay('comment', 'comment')->getComponent('subject')) {
      // Subject input allowed.       $edit['subject[0][value]'] = $subject;
    }
    else {
      $this->assertSession()->fieldValueNotEquals('subject[0][value]', '');
    }

    if ($contact !== NULL && is_array($contact)) {
      $edit += $contact;
    }
    switch ($preview_mode) {
      case DRUPAL_REQUIRED:
        // Preview required so no save button should be found.         $this->assertSession()->buttonNotExists('Save');
        $this->submitForm($edit, 'Preview');
        // Don't break here so that we can test post-preview field presence and

    $this->drupalGet('user/login');
    $this->submitForm($edit, 'Log in');
    $this->assertSession()->pageTextContains("Unrecognized username or password. Forgot your password?");
    $this->assertSession()->linkExists("Forgot your password?");
    $this->assertSession()->linkByHrefExists(Url::fromRoute('user.pass', []['query' => ['name' => $edit['name']]])->toString());
    unset($edit['pass']);
    $this->drupalGet('user/password', ['query' => ['name' => $edit['name']]]);
    $this->assertSession()->fieldValueEquals('name', $edit['name']);
    // Ensure the name field value is not cached.     $this->drupalGet('user/password');
    $this->assertSession()->fieldValueNotEquals('name', $edit['name']);
  }

  /** * Tests password reset flood control for one user. */
  public function testUserResetPasswordUserFloodControl() {
    \Drupal::configFactory()->getEditable('user.flood')
      ->set('user_limit', 3)
      ->save();

    $edit = ['name' => $this->account->getAccountName()];

    


    // Now test by submitting the or/not part of the query in the main     // search box, and verify that the advanced form is not filled out.     // (It shouldn't be filled out unless you submit values in those fields.)     $edit2 = ['keys' => 'cat dog OR gerbil -fish -snake'];
    $this->drupalGet('search/node');
    $this->submitForm($edit2, 'edit-submit--2');
    $this->assertSession()->pageTextContains('Search for cat dog OR gerbil -fish -snake');
    foreach ($edit as $key => $value) {
      if ($key != 'type[page]') {
        $this->assertSession()->fieldValueNotEquals($key$value);
      }
    }
  }

}
/** * Tests legacy field asserts which use xpath directly. */
  public function testXpathAsserts() {
    $this->drupalGet('test-field-xpath');
    $this->assertSession()->elementTextContains('xpath', '//table/tbody/tr[2]/td[1]', 'one');

    $this->assertSession()->fieldValueEquals('edit-name', 'Test name');
    $this->assertSession()->fieldValueEquals('edit-options', '2');

    $this->assertSession()->elementNotExists('xpath', '//notexisting');
    $this->assertSession()->fieldValueNotEquals('edit-name', 'wrong value');

    // Test that the assertion fails correctly.     try {
      $this->assertSession()->fieldExists('notexisting');
      $this->fail('The "notexisting" field was found.');
    }
    catch (ExpectationException $e) {
      // Expected exception; just continue testing.     }

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