You are here

public function TwigExtensionFiltersTest::testSetFilterMissingArgumentException in Components! 8.2

Tests exceptions during set filter.

@covers ::setFilter

File

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

Class

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

Namespace

Drupal\Tests\components\Unit

Code

public function testSetFilterMissingArgumentException() {
  try {
    TwigExtension::setFilter([
      'an-array',
    ], NULL, 'value');
    $exception = FALSE;
  } catch (\Exception $e) {
    $this
      ->assertStringContainsString('Value for argument "at" is required for filter "set".', $e
      ->getMessage());
    $exception = TRUE;
  }
  if (!$exception) {
    $this
      ->fail('Expected Exception, none was thrown.');
  }
}