function JsWebAssertTestForm::buildForm

Same name in this branch
  1. 11.x core/modules/system/tests/modules/js_webassert_test/src/Form/JsWebAssertTestForm.php \Drupal\js_webassert_test\Form\JsWebAssertTestForm::buildForm()
Same name in other branches
  1. 9 core/modules/system/tests/modules/js_webassert_test/src/Form/JsWebAssertTestForm.php \Drupal\js_webassert_test\Form\JsWebAssertTestForm::buildForm()
  2. 8.9.x core/modules/system/tests/modules/js_webassert_test/src/Form/JsWebAssertTestForm.php \Drupal\js_webassert_test\Form\JsWebAssertTestForm::buildForm()
  3. 10 core/modules/system/tests/modules/js_webassert_test/src/Form/JsWebAssertTestForm.php \Drupal\js_webassert_test\Form\JsWebAssertTestForm::buildForm()

Form for testing the addition of various types of elements via AJAX.

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/jswebassert_test/src/Form/JsWebAssertTestForm.php, line 28

Class

JsWebAssertTestForm
Test form for JSWebAssert WebDriverTestBase.

Namespace

Drupal\jswebassert_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#prefix'] = '<div id="jswebassert_test_form_wrapper">';
    $form['#suffix'] = '</div>';
    // Button to test for the waitForButton() assertion.
    $form['test_button'] = [
        '#type' => 'submit',
        '#value' => $this->t('Add button'),
        '#button_type' => 'primary',
        '#ajax' => [
            'callback' => 'Drupal\\jswebassert_test\\Form\\JsWebAssertTestForm::addButton',
            'progress' => [
                'type' => 'throbber',
                'message' => NULL,
            ],
            'wrapper' => 'jswebassert_test_form_wrapper',
        ],
    ];
    // Button to test for the waitForLink() assertion.
    $form['test_link'] = [
        '#type' => 'submit',
        '#value' => $this->t('Add link'),
        '#button_type' => 'primary',
        '#ajax' => [
            'callback' => 'Drupal\\jswebassert_test\\Form\\JsWebAssertTestForm::addLink',
            'progress' => [
                'type' => 'throbber',
                'message' => NULL,
            ],
            'wrapper' => 'jswebassert_test_form_wrapper',
        ],
    ];
    // Button to test for the waitForField() assertion.
    $form['test_field'] = [
        '#type' => 'submit',
        '#value' => $this->t('Add field'),
        '#button_type' => 'primary',
        '#ajax' => [
            'callback' => 'Drupal\\jswebassert_test\\Form\\JsWebAssertTestForm::addField',
            'progress' => [
                'type' => 'throbber',
                'message' => NULL,
            ],
            'wrapper' => 'jswebassert_test_form_wrapper',
        ],
    ];
    // Button to test for the waitForId() assertion.
    $form['test_id'] = [
        '#type' => 'submit',
        '#value' => $this->t('Add ID'),
        '#button_type' => 'primary',
        '#ajax' => [
            'callback' => 'Drupal\\jswebassert_test\\Form\\JsWebAssertTestForm::addId',
            'progress' => [
                'type' => 'throbber',
                'message' => NULL,
            ],
            'wrapper' => 'jswebassert_test_form_wrapper',
        ],
    ];
    // Button to test the assertWaitOnAjaxRequest() assertion.
    $form['test_wait_for_element_visible'] = [
        '#type' => 'submit',
        '#value' => $this->t('Test waitForElementVisible'),
        '#button_type' => 'primary',
        '#ajax' => [
            'callback' => 'Drupal\\jswebassert_test\\Form\\JsWebAssertTestForm::addWaitForElementVisible',
            'progress' => [
                'type' => 'throbber',
                'message' => NULL,
            ],
            'wrapper' => 'jswebassert_test_form_wrapper',
        ],
    ];
    // Button to test the assertWaitOnAjaxRequest() assertion.
    $form['test_assert_wait_on_ajax_request'] = [
        '#type' => 'submit',
        '#value' => $this->t('Test assertWaitOnAjaxRequest'),
        '#button_type' => 'primary',
        '#ajax' => [
            'callback' => 'Drupal\\jswebassert_test\\Form\\JsWebAssertTestForm::addAssertWaitOnAjaxRequest',
            'progress' => [
                'type' => 'throbber',
                'message' => NULL,
            ],
            'wrapper' => 'jswebassert_test_form_wrapper',
        ],
    ];
    // Button to test the assertNoElementAfterWait() assertion, will pass.
    $form['test_assert_no_element_after_wait_pass'] = [
        '#type' => 'submit',
        '#value' => $this->t('Test assertNoElementAfterWait: pass'),
        '#button_type' => 'primary',
        '#attached' => [
            'library' => 'jswebassert_test/no_element_after_wait',
        ],
    ];
    // Button to test the assertNoElementAfterWait() assertion, will fail.
    $form['test_assert_no_element_after_wait_fail'] = [
        '#type' => 'submit',
        '#value' => $this->t('Test assertNoElementAfterWait: fail'),
        '#button_type' => 'primary',
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.