function FormStateDecoratorBaseTest::testGetTriggeringElement

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php \Drupal\Tests\Core\Form\FormStateDecoratorBaseTest::testGetTriggeringElement()
  2. 8.9.x core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php \Drupal\Tests\Core\Form\FormStateDecoratorBaseTest::testGetTriggeringElement()
  3. 11.x core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php \Drupal\Tests\Core\Form\FormStateDecoratorBaseTest::testGetTriggeringElement()

@covers ::getTriggeringElement

File

core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php, line 759

Class

FormStateDecoratorBaseTest
@coversDefaultClass \Drupal\Core\Form\FormStateDecoratorBase[[api-linebreak]]

Namespace

Drupal\Tests\Core\Form

Code

public function testGetTriggeringElement() : void {
  $triggering_element = [
    'FOO' => 'BAR',
  ];
  // Use PHPUnit for mocking, because Prophecy cannot mock methods that return
  // by reference. See \Prophecy\Doubler\Generator\Node::getCode().
  $decorated_form_state = $this->createMock(FormStateInterface::class);
  $decorated_form_state->expects($this->once())
    ->method('getTriggeringElement')
    ->willReturn($triggering_element);
  $this->formStateDecoratorBase = new NonAbstractFormStateDecoratorBase($decorated_form_state);
  $this->assertSame($triggering_element, $this->formStateDecoratorBase
    ->getTriggeringElement());
}

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