1<?php 2 3/* 4 * This file is part of Twig. 5 * 6 * (c) Fabien Potencier 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12use Twig\FileExtensionEscapingStrategy; 13 14class Twig_Tests_FileExtensionEscapingStrategyTest extends \PHPUnit\Framework\TestCase 15{ 16 /** 17 * @dataProvider getGuessData 18 */ 19 public function testGuess($strategy, $filename) 20 { 21 $this->assertSame($strategy, FileExtensionEscapingStrategy::guess($filename)); 22 } 23 24 public function getGuessData() 25 { 26 return [ 27 // default 28 ['html', 'foo.html'], 29 ['html', 'foo.html.twig'], 30 ['html', 'foo'], 31 ['html', 'foo.bar.twig'], 32 ['html', 'foo.txt/foo'], 33 ['html', 'foo.txt/foo.js/'], 34 35 // css 36 ['css', 'foo.css'], 37 ['css', 'foo.css.twig'], 38 ['css', 'foo.twig.css'], 39 ['css', 'foo.js.css'], 40 ['css', 'foo.js.css.twig'], 41 42 // js 43 ['js', 'foo.js'], 44 ['js', 'foo.js.twig'], 45 ['js', 'foo.txt/foo.js'], 46 ['js', 'foo.txt.twig/foo.js'], 47 48 // txt 49 [false, 'foo.txt'], 50 [false, 'foo.txt.twig'], 51 ]; 52 } 53} 54