function WizardPluginBaseTest::testGetSelected

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/WizardPluginBaseTest.php \Drupal\Tests\views\Unit\WizardPluginBaseTest::testGetSelected()
  2. 8.9.x core/modules/views/tests/src/Unit/WizardPluginBaseTest.php \Drupal\Tests\views\Unit\WizardPluginBaseTest::testGetSelected()
  3. 10 core/modules/views/tests/src/Unit/WizardPluginBaseTest.php \Drupal\Tests\views\Unit\WizardPluginBaseTest::testGetSelected()

@covers ::getSelected

@dataProvider providerTestGetSelected

File

core/modules/views/tests/src/Unit/WizardPluginBaseTest.php, line 23

Class

WizardPluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\wizard\WizardPluginBase

Namespace

Drupal\Tests\views\Unit

Code

public function testGetSelected($expected, $element = [], $parents = [], $user_input = [], $not_rebuilding_expected = NULL) : void {
    $not_rebuilding_expected = $not_rebuilding_expected ?: $expected;
    $form_state = new FormState();
    $form_state->setUserInput($user_input);
    $actual = WizardPluginBase::getSelected($form_state, $parents, 'the_default_value', $element);
    $this->assertSame($not_rebuilding_expected, $actual);
    $this->assertSame($user_input, $form_state->getUserInput());
    $form_state->setRebuild();
    $actual = WizardPluginBase::getSelected($form_state, $parents, 'the_default_value', $element);
    $this->assertSame($expected, $actual);
    $this->assertSame($user_input, $form_state->getUserInput());
}

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