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