public function TwigExtensionFiltersTest::testSetFilterException in Components! 3.x
Same name and namespace in other branches
- 8.2 tests/src/Unit/TwigExtensionFiltersTest.php \Drupal\Tests\components\Unit\TwigExtensionFiltersTest::testSetFilterException()
Tests exceptions during set filter.
@covers ::setFilter
File
- tests/
src/ Unit/ TwigExtensionFiltersTest.php, line 143
Class
- TwigExtensionFiltersTest
- @coversDefaultClass \Drupal\components\Template\TwigExtension @group components
Namespace
Drupal\Tests\components\UnitCode
public function testSetFilterException() {
try {
TwigExtension::setFilter('not-an-array', 'key', 'value');
$exception = FALSE;
} catch (\Exception $e) {
$this
->assertStringContainsString('The set filter only works on arrays or "Traversable" objects, got "string".', $e
->getMessage());
$exception = TRUE;
}
if (!$exception) {
$this
->fail('Expected Exception, none was thrown.');
}
}