$container =
$this->
createContainer();
$container->
setParameter('kernel.debug',
$debug);
if ($stopwatchEnabled) { $container->
register('debug.stopwatch', Stopwatch::
class);
} $container->
registerExtension(new TwigExtension());
$container->
loadFromExtension('twig'
);
$container->
setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch'
)->
setPublic(true
);
$this->
compileContainer($container);
$tokenParsers =
$container->
get('test.twig.extension.debug.stopwatch'
)->
getTokenParsers();
$stopwatchIsAvailable =
new \
ReflectionProperty($tokenParsers[0
], 'stopwatchIsAvailable'
);
$this->
assertSame($expected,
$stopwatchIsAvailable->
getValue($tokenParsers[0
]));
} public static function stopwatchExtensionAvailabilityProvider() { return [ 'debug-and-stopwatch-enabled' =>
[true, true, true
],
'only-stopwatch-enabled' =>
[false, true, false
],
'only-debug-enabled' =>
[true, false, false
],