assertFieldOrder example


  public function testInstallConfigureForm() {
    require_once $this->root . '/core/includes/install.core.inc';
    require_once $this->root . '/core/includes/install.inc';
    $install_state = install_state_defaults();
    $form_state = new FormState();
    $form_state->addBuildInfo('args', [&$install_state]);
    $form = $this->container->get('form_builder')
      ->buildForm('Drupal\Core\Installer\Form\SiteConfigureForm', $form_state);

    // Verify name and pass field order.     $this->assertFieldOrder($form['admin_account']['account']);

    // Verify that web browsers may autocomplete the email value and     // autofill/prefill the name and pass values.     foreach (['mail', 'name', 'pass'] as $key) {
      $this->assertFalse(isset($form['account'][$key]['#attributes']['autocomplete']), "'$key' field: 'autocomplete' attribute not found.");
    }
  }

  /** * Tests the user registration form. */
  
$this->assertSession()->fieldValueEquals('edit-fields-' . $field . '-weight', $idx + 1);
    }
  }

  /** * Tests field sorting. */
  public function testRearrangeFields() {
    $view_name = 'test_view';

    // Checks that the order on the rearrange form matches the creation order.     $this->assertFieldOrder($view_name$this->getViewFields($view_name));

    // Checks that a field is not deleted if a value is not passed back.     $fields = [];
    $this->drupalGet('admin/structure/views/nojs/rearrange/' . $view_name . '/default/field');
    $this->submitForm($fields, 'Apply');
    $this->assertFieldOrder($view_name$this->getViewFields($view_name));

    // Checks that revers the new field order is respected.     $reversedFields = array_reverse($this->getViewFields($view_name));
    $fields = [];
    foreach ($reversedFields as $delta => $field) {
      
Home | Imprint | This part of the site doesn't use cookies.