BootstrapIconExtensionTest.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * This file is part of BcBootstrapBundle.
  4. *
  5. * (c) 2012-2013 by Florian Eckerstorfer
  6. */
  7. namespace Bc\Bundle\BootstrapBundle\Tests\Twig;
  8. use Bc\Bundle\BootstrapBundle\Twig\BootstrapIconExtension;
  9. /**
  10. * BootstrapIconExtensionTest
  11. *
  12. * @category Test
  13. * @package BraincraftedBootstrapBundle
  14. * @subpackage Twig
  15. * @author Florian Eckerstorfer <florian@eckerstorfer.co>
  16. * @copyright 2012-2013 Florian Eckerstorfer
  17. * @license http://opensource.org/licenses/MIT The MIT License
  18. * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2
  19. */
  20. class BootstrapIconExtensionTest extends \PHPUnit_Framework_TestCase
  21. {
  22. /** @var \Braincrafted\BootstrapBundle\Twig\BootstrapIconExtension */
  23. private $extension;
  24. /**
  25. * Set up
  26. */
  27. public function setUp()
  28. {
  29. $this->extension = new BootstrapIconExtension();
  30. }
  31. /**
  32. * @covers Braincrafted\BootstrapBundle\Twig\BootstrapIconExtension::iconFilter
  33. */
  34. public function testIconFilter()
  35. {
  36. $this->assertEquals(
  37. '<i class="icon-heart"></i>',
  38. $this->extension->iconFilter('heart'),
  39. '->iconFilter() returns the HTML code for the given icon.'
  40. );
  41. $this->assertEquals(
  42. '<i class="icon-white icon-heart"></i>',
  43. $this->extension->iconFilter('heart', 'white'),
  44. '->iconFilter() returns the HTML code for the given icon in white.'
  45. );
  46. }
  47. /**
  48. * @covers Braincrafted\BootstrapBundle\Twig\BootstrapIconExtension::parseIconsFilter
  49. */
  50. public function testParseIconsFilter()
  51. {
  52. $this->assertEquals(
  53. '<i class="icon-heart"></i> foobar',
  54. $this->extension->parseIconsFilter('.icon-heart foobar'),
  55. '->parseIconsFilter() returns the HTML code with the replaced icons.'
  56. );
  57. $this->assertEquals(
  58. '<i class="icon-white icon-heart"></i> foobar',
  59. $this->extension->parseIconsFilter('.icon-heart foobar', 'white'),
  60. '->parseIconsFilter() returns the HTML code with the replaced icons in white.'
  61. );
  62. }
  63. /**
  64. * @covers Braincrafted\BootstrapBundle\Twig\BootstrapIconExtension::getFilters
  65. */
  66. public function testGetFilters()
  67. {
  68. $filters = $this->extension->getFilters();
  69. $this->assertCount(2, $filters, '->getFilters() returns 2 filters.');
  70. $this->assertTrue(isset($filters['parse_icons']), '->getFilters() returns "parse_icons" filter.');
  71. $this->assertTrue(isset($filters['icon']), '->getFilters() returns "icon" filter.');
  72. }
  73. /**
  74. * @covers Braincrafted\BootstrapBundle\Twig\BootstrapIconExtension::getName
  75. */
  76. public function testGetName()
  77. {
  78. $this->assertEquals('bootstrap_icon_extension', $this->extension->getName(), '->getName() returns the name.');
  79. }
  80. }