mglaman / drupal-test-helpers

Helpers for writing better Kernel and Unit tests for Drupal
GNU General Public License v2.0
10 stars 2 forks source link

submitting forms #3

Closed mglaman closed 1 year ago

mglaman commented 1 year ago
    $form_data = [
      'name' => 'foo',
      'pass' => 'barbaz',
      // @phpstan-ignore-next-line
      'form_build_id' => (string) $this->cssSelect('input[name="form_build_id"]')[0]->attributes()->value[0],
      // @phpstan-ignore-next-line
      'form_id' => (string) $this->cssSelect('input[name="form_id"]')[0]->attributes()->value[0],
      // @phpstan-ignore-next-line
      'op' => (string) $this->cssSelect('input[name="op"]')[0]->attributes()->value[0],
    ];

Example for performing a login. needs to handle form_token if authenticated for CSRF