/Tests/Twig/Extension/FacebookExtensionTest.php

http://github.com/FriendsOfSymfony/FOSFacebookBundle · PHP · 82 lines · 53 code · 9 blank · 20 comment · 0 complexity · fe833f59b16ec9ab6e0d531e204f3b00 MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of the FOSFacebookBundle package.
  4. *
  5. * (c) FriendsOfSymfony <http://friendsofsymfony.github.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 FOS\FacebookBundle\Tests\Twig\Extension;
  11. use FOS\FacebookBundle\Twig\Extension\FacebookExtension;
  12. use FOS\FacebookBundle\Templating\Helper\FacebookHelper;
  13. class FacebookExtensionTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @covers FOS\FacebookBundle\Twig\Extension\FacebookExtension::getName
  17. */
  18. public function testGetName()
  19. {
  20. $containerMock = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  21. $extension = new FacebookExtension($containerMock);
  22. $this->assertSame('facebook', $extension->getName());
  23. }
  24. /**
  25. * @covers FOS\FacebookBundle\Twig\Extension\FacebookExtension::getFunctions
  26. */
  27. public function testGetFunctions()
  28. {
  29. $containerMock = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  30. $extension = new FacebookExtension($containerMock);
  31. $functions = $extension->getFunctions();
  32. $this->assertInstanceOf('\Twig_Function_Method', $functions['facebook_initialize']);
  33. $this->assertInstanceOf('\Twig_Function_Method', $functions['facebook_login_button']);
  34. }
  35. /**
  36. * @covers FOS\FacebookBundle\Twig\Extension\FacebookExtension::renderInitialize
  37. */
  38. public function testRenderInitialize()
  39. {
  40. $helperMock = $this->getMockBuilder('FOS\FacebookBundle\Templating\Helper\FacebookHelper')
  41. ->disableOriginalConstructor()
  42. ->getMock();
  43. $helperMock->expects($this->once())
  44. ->method('initialize')
  45. ->will($this->returnValue('returnedValue'));
  46. $containerMock = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  47. $containerMock->expects($this->once())
  48. ->method('get')
  49. ->with('fos_facebook.helper')
  50. ->will($this->returnValue($helperMock));
  51. $extension = new FacebookExtension($containerMock);
  52. $this->assertSame('returnedValue', $extension->renderInitialize());
  53. }
  54. /**
  55. * @covers FOS\FacebookBundle\Twig\Extension\FacebookExtension::renderloginButton
  56. */
  57. public function testRenderLoginButton()
  58. {
  59. $helperMock = $this->getMockBuilder('FOS\FacebookBundle\Templating\Helper\FacebookHelper')
  60. ->disableOriginalConstructor()
  61. ->getMock();
  62. $helperMock->expects($this->once())
  63. ->method('loginButton')
  64. ->will($this->returnValue('returnedValueLogin'));
  65. $containerMock = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  66. $containerMock->expects($this->once())
  67. ->method('get')
  68. ->with('fos_facebook.helper')
  69. ->will($this->returnValue($helperMock));
  70. $extension = new FacebookExtension($containerMock);
  71. $this->assertSame('returnedValueLogin', $extension->renderLoginButton());
  72. }
  73. }