CodeHelperTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
  11. use Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper;
  12. class CodeHelperTest extends \PHPUnit_Framework_TestCase
  13. {
  14. protected static $helper;
  15. static public function setUpBeforeClass()
  16. {
  17. self::$helper = new CodeHelper('format', '/root');
  18. }
  19. /**
  20. * @dataProvider getClassNameProvider
  21. */
  22. public function testGettingClassAbbreviation($class, $abbr)
  23. {
  24. $this->assertEquals(self::$helper->abbrClass($class), $abbr);
  25. }
  26. /**
  27. * @dataProvider getMethodNameProvider
  28. */
  29. public function testGettingMethodAbbreviation($method, $abbr)
  30. {
  31. $this->assertEquals(self::$helper->abbrMethod($method), $abbr);
  32. }
  33. public function getClassNameProvider()
  34. {
  35. return array(
  36. array('F\Q\N\Foo', '<abbr title="F\Q\N\Foo">Foo</abbr>'),
  37. array('Bare', '<abbr title="Bare">Bare</abbr>'),
  38. );
  39. }
  40. public function getMethodNameProvider()
  41. {
  42. return array(
  43. array('F\Q\N\Foo::Method', '<abbr title="F\Q\N\Foo">Foo</abbr>::Method()'),
  44. array('Bare::Method', '<abbr title="Bare">Bare</abbr>::Method()'),
  45. array('Closure', '<abbr title="Closure">Closure</abbr>'),
  46. array('Method', '<abbr title="Method">Method</abbr>()')
  47. );
  48. }
  49. public function testGetName()
  50. {
  51. $this->assertEquals('code', self::$helper->getName());
  52. }
  53. }