You are here

function AsafCommonTests::testFormSubmit in Asaf (ajax submit for any form) 7

Same name and namespace in other branches
  1. 8 tests/asaf.test \AsafCommonTests::testFormSubmit()

File

tests/asaf.test, line 93

Class

AsafCommonTests

Code

function testFormSubmit() {
  $this
    ->drupalGet('examples/asaf_example/api/simplest');
  $this
    ->initAsafFormWrapper();
  $buttonIds = array_keys($this
    ->getButtons('asaf-example-api-simplest'));
  $buttonId = reset($buttonIds);
  $settings = $this
    ->drupalGetSettings();
  $ajax_setting = $settings['ajax'][$buttonId];
  $this
    ->drupalPostAJAX(NULL, array(), 'op', NULL, array(), array(), NULL, $ajax_setting);
  $this
    ->assertText('Name field is required.', t('Checking ajax validate'));
  $edit = array(
    'name' => t('Anka'),
  );
  $this
    ->drupalGet('examples/asaf_example/api/simplest');
  $this
    ->initAsafFormWrapper();
  $buttonIds = array_keys($this
    ->getButtons('asaf-example-api-simplest'));
  $buttonId = reset($buttonIds);
  $settings = $this
    ->drupalGetSettings();
  $ajax_setting = $settings['ajax'][$buttonId];
  $this
    ->drupalPostAJAX(NULL, $edit, 'op', NULL, array(), array(), NULL, $ajax_setting);
  $this
    ->assertText('Specified name: Anka', t('Checking ajax submit'));
}