You are here

YamlFormElementOptionsTest.php in YAML Form 8

File

src/Tests/YamlFormElementOptionsTest.php
View source
<?php

namespace Drupal\yamlform\Tests;

use Drupal\simpletest\WebTestBase;

/**
 * Tests for form element options.
 *
 * @group YamlForm
 */
class YamlFormElementOptionsTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'system',
    'user',
    'yamlform',
    'yamlform_test',
  ];

  /**
   * Tests building of options elements.
   */
  public function test() {
    global $base_path;

    /**************************************************************************/

    // Processing.

    /**************************************************************************/

    // Check default value handling.
    $this
      ->drupalPostForm('yamlform/test_element_options', [], t('Submit'));
    $this
      ->assertRaw("yamlform_options: {  }\nyamlform_options_default_value:\n  one: One\n  two: Two\n  three: Three\nyamlform_options_optgroup:\n  'Group One':\n    one: One\n  'Group Two':\n    two: Two\n  'Group Three':\n    three: Three\nyamlform_element_options_entity: yes_no\nyamlform_element_options_custom:\n  one: One\n  two: Two\n  three: Three");

    // Check default value handling.
    $this
      ->drupalPostForm('yamlform/test_element_options', [
      'yamlform_element_options_custom[options]' => 'yes_no',
    ], t('Submit'));
    $this
      ->assertRaw("yamlform_element_options_custom: yes_no");
  }

}

Classes

Namesort descending Description
YamlFormElementOptionsTest Tests for form element options.