You are here

public function TwigExtensionFiltersTest::testSetFilter in Components! 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/TwigExtensionFiltersTest.php \Drupal\Tests\components\Unit\TwigExtensionFiltersTest::testSetFilter()

Tests the set filter.

@covers ::setFilter

@dataProvider providerTestSetFilter

Parameters

array $element: The element to alter.

string $at: The dotted-path to the deeply nested element to set.

mixed $value: The value to set.

array $expected: The expected result.

File

tests/src/Unit/TwigExtensionFiltersTest.php, line 173

Class

TwigExtensionFiltersTest
@coversDefaultClass \Drupal\components\Template\TwigExtension @group components

Namespace

Drupal\Tests\components\Unit

Code

public function testSetFilter(array $element, string $at, $value, array $expected) {
  $result = NULL;
  try {
    $result = TwigExtension::setFilter($element, $at, $value);
  } catch (\Exception $e) {
    $this
      ->fail('No Exception expected; "' . $e
      ->getMessage() . '" thrown during: ' . $this
      ->getName());
  }
  $this
    ->assertEquals($expected, $result, $this
    ->getName());
}