createMock(LoaderInterface::class)); $twig->addFunction(new TwigFunction('deprec', [$this, 'deprec'], ['deprecated' => true])); $collector = new DeprecationCollector($twig); $deprecations = $collector->collect(new Twig_Tests_Util_Iterator()); $this->assertEquals(['Twig Function "deprec" is deprecated in deprec.twig at line 1.'], $deprecations); } public function deprec() { } } class Twig_Tests_Util_Iterator implements \IteratorAggregate { public function getIterator(): \Traversable { return new \ArrayIterator([ 'ok.twig' => '{{ foo }}', 'deprec.twig' => '{{ deprec("foo") }}', ]); } }