4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Bridge\Twig\Tests\Extension
;
14 use Symfony\Bridge\Twig\Extension\CodeExtension
;
16 class CodeExtensionTest
extends \PHPUnit_Framework_TestCase
20 public function testFormatFile()
22 $expected = sprintf('<a href="txmt://open?url=file://%s&line=25" title="Click to open this file" class="file_link">%s at line 25</a>', __FILE__
, __FILE__
);
23 $this->assertEquals($expected, $this->getExtension()->formatFile(__FILE__
, 25));
27 * @dataProvider getClassNameProvider
29 public function testGettingClassAbbreviation($class, $abbr)
31 $this->assertEquals($this->getExtension()->abbrClass($class), $abbr);
35 * @dataProvider getMethodNameProvider
37 public function testGettingMethodAbbreviation($method, $abbr)
39 $this->assertEquals($this->getExtension()->abbrMethod($method), $abbr);
42 public function getClassNameProvider()
45 array('F\Q\N\Foo', '<abbr title="F\Q\N\Foo">Foo</abbr>'),
46 array('Bare', '<abbr title="Bare">Bare</abbr>'),
50 public function getMethodNameProvider()
53 array('F\Q\N\Foo::Method', '<abbr title="F\Q\N\Foo">Foo</abbr>::Method()'),
54 array('Bare::Method', '<abbr title="Bare">Bare</abbr>::Method()'),
55 array('Closure', '<abbr title="Closure">Closure</abbr>'),
56 array('Method', '<abbr title="Method">Method</abbr>()')
60 public function testGetName()
62 $this->assertEquals('code', $this->getExtension()->getName());
65 protected function getExtension()
67 return new CodeExtension('txmt://open?url=file://%f&line=%l', '/root', 'UTF-8');