diff options
Diffstat (limited to 'vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php')
-rw-r--r-- | vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php b/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php new file mode 100644 index 00000000..d9356514 --- /dev/null +++ b/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php | |||
@@ -0,0 +1,69 @@ | |||
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&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 | } | ||