You are here

public function SelectOrOtherWidgetBaseTest::testSettingsSummary in Select (or other) 8.3

Tests the functionality of SelectOrOtherWidgetBase::settingsSummary

File

tests/src/Unit/SelectOrOtherWidgetBaseTest.php, line 110

Class

SelectOrOtherWidgetBaseTest
Tests the form element implementation.

Namespace

Drupal\tests\select_or_other\Unit

Code

public function testSettingsSummary() {

  /** @var SelectOrOtherWidgetBase $mock */
  $mock = $this->widgetBaseMock;
  $elementTypeOptions = new ReflectionMethod($this::$testedClassName, 'selectElementTypeOptions');
  $elementTypeOptions
    ->setAccessible(TRUE);
  $options = $elementTypeOptions
    ->invoke($mock);
  foreach ($options as $option => $label) {
    $mock
      ->setSetting('select_element_type', $option);
    $expected = [
      'Type of select form element: ' . $label,
    ];
    $summary = $mock
      ->settingsSummary();
    $this
      ->assertArrayEquals($expected, $summary);
  }
}