You are here

public function TwigExtensionFiltersTest::testSetFilter in Components! 8.2

Same name and namespace in other branches
  1. 3.x 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|array $at: The dotted-path to the deeply nested element to set. (Or an array value to merge, if using the backwards-compatible 8.x-2.x syntax.)

mixed $value: The value to set.

array $expected: The expected result.

File

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

Class

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

Namespace

Drupal\Tests\components\Unit

Code

public function testSetFilter(array $element, $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());
}