$this->
fail('Expected exception not thrown'
);
} catch (LoaderError
$e) { $this->
assertStringContainsString('Template @__main__\/core/tests/fixtures/files/sql-2.sql has an invalid file extension (sql). Only templates ending in one of css, html, js, svg, twig are allowed. Set the twig.config.allowed_file_extensions container parameter to customize the allowed file extensions',
$e->
getMessage());
} // Allow SQL files to be included.
$twig_config =
$this->container->
getParameter('twig.config'
);
$twig_config['allowed_file_extensions'
][] = 'sql';
$this->twigConfig =
$twig_config;
$this->container->
get('kernel'
)->
shutdown();
$this->container->
get('kernel'
)->
boot();
/** @var \Drupal\Core\Template\Loader\FilesystemLoader $loader */
$loader = \Drupal::
service('twig.loader.filesystem'
);
$source =
$loader->
getSourceContext('@__main__\/core/tests/fixtures/files/sql-2.sql'
);
$this->
assertSame(file_get_contents('core/tests/fixtures/files/sql-2.sql'
),
$source->
getCode());
// Test the fallback to the default list of extensions provided by the
// class.
$this->
assertSame(['css', 'html', 'js', 'svg', 'twig', 'sql'
], \Drupal::
getContainer()->
getParameter('twig.config'
)['allowed_file_extensions'
]);
unset($twig_config['allowed_file_extensions'
]);
$this->twigConfig =
$twig_config;
$this->container->
get('kernel'
)->
shutdown();