]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php
d93565143972c8982c4028171646824daa611fb7
[github/wallabag/wallabag.git] / vendor / symfony / twig-bridge / Symfony / Bridge / Twig / Tests / Extension / CodeExtensionTest.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Bridge\Twig\Tests\Extension;
13
14 use Symfony\Bridge\Twig\Extension\CodeExtension;
15
16 class CodeExtensionTest extends \PHPUnit_Framework_TestCase
17 {
18 protected $helper;
19
20 public function testFormatFile()
21 {
22 $expected = sprintf('<a href="txmt://open?url=file://%s&amp;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));
24 }
25
26 /**
27 * @dataProvider getClassNameProvider
28 */
29 public function testGettingClassAbbreviation($class, $abbr)
30 {
31 $this->assertEquals($this->getExtension()->abbrClass($class), $abbr);
32 }
33
34 /**
35 * @dataProvider getMethodNameProvider
36 */
37 public function testGettingMethodAbbreviation($method, $abbr)
38 {
39 $this->assertEquals($this->getExtension()->abbrMethod($method), $abbr);
40 }
41
42 public function getClassNameProvider()
43 {
44 return array(
45 array('F\Q\N\Foo', '<abbr title="F\Q\N\Foo">Foo</abbr>'),
46 array('Bare', '<abbr title="Bare">Bare</abbr>'),
47 );
48 }
49
50 public function getMethodNameProvider()
51 {
52 return array(
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>()')
57 );
58 }
59
60 public function testGetName()
61 {
62 $this->assertEquals('code', $this->getExtension()->getName());
63 }
64
65 protected function getExtension()
66 {
67 return new CodeExtension('txmt://open?url=file://%f&line=%l', '/root', 'UTF-8');
68 }
69 }