4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Tests_Util_DeprecationCollectorTest extends PHPUnit_Framework_TestCase
17 public function testCollect()
19 $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
20 $twig->addFunction(new Twig_SimpleFunction('deprec', array($this, 'deprec'), array('deprecated' => true)));
22 $collector = new Twig_Util_DeprecationCollector($twig);
23 $deprecations = $collector->collect(new Twig_Tests_Util_Iterator());
25 $this->assertEquals(array('Twig Function "deprec" is deprecated in deprec.twig at line 1.'), $deprecations);
28 public function deprec()
33 class Twig_Tests_Util_Iterator implements IteratorAggregate
35 public function getIterator()
37 return new ArrayIterator(array(
38 'ok.twig' => '{{ foo }}',
39 'deprec.twig' => '{{ deprec("foo") }}',