/Tests/Templating/Helper/FacebookHelperTest.php
http://github.com/FriendsOfSymfony/FOSFacebookBundle · PHP · 107 lines · 78 code · 15 blank · 14 comment · 0 complexity · 21b9440e1e9d1b4130d7b5f422644666 MD5 · raw file
- <?php
- /*
- * This file is part of the FOSFacebookBundle package.
- *
- * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace FOS\FacebookBundle\Tests\Templating\Helper;
- use FOS\FacebookBundle\Templating\Helper\FacebookHelper;
- class FacebookHelperTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * @covers FOS\FacebookBundle\Templating\Helper\FacebookHelper::initialize
- */
- public function testInitialize()
- {
- $expected = new \stdClass();
- $templating = $this->getMockBuilder('Symfony\Component\Templating\DelegatingEngine')
- ->disableOriginalConstructor()
- ->getMock();
- $templating
- ->expects($this->once())
- ->method('render')
- ->with('FOSFacebookBundle::initialize.html.php', array(
- 'appId' => 123,
- 'async' => true,
- 'cookie' => false,
- 'culture' => 'en_US',
- 'fbAsyncInit' => '',
- 'logging' => true,
- 'oauth' => true,
- 'status' => false,
- 'channelUrl' => '/channel.html',
- 'xfbml' => false,
- ))
- ->will($this->returnValue($expected));
- $facebookMock = $this->getMockBuilder('FOS\FacebookBundle\Facebook\FacebookSessionPersistence')
- ->disableOriginalConstructor()
- ->setMethods(array('getAppId'))
- ->getMock();
- $routing = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')
- ->disableOriginalConstructor()
- ->getMock();
- $routing
- ->expects($this->once())
- ->method('generate')
- ->will($this->returnValue('/channel.html'));
- $facebookMock->expects($this->once())
- ->method('getAppId')
- ->will($this->returnValue('123'));
- $helper = new FacebookHelper($templating, $facebookMock, $routing);
- $this->assertSame($expected, $helper->initialize(array('cookie' => false)));
- }
- /**
- * @covers FOS\FacebookBundle\Templating\Helper\FacebookHelper::loginButton
- */
- public function testLoginButton()
- {
- $expected = new \stdClass();
- $templating = $this->getMockBuilder('Symfony\Component\Templating\DelegatingEngine')
- ->disableOriginalConstructor()
- ->getMock();
- $templating
- ->expects($this->once())
- ->method('render')
- ->with('FOSFacebookBundle::loginButton.html.php', array(
- 'autologoutlink' => 'false',
- 'label' => 'testLabel',
- 'showFaces' => 'false',
- 'width' => '',
- 'maxRows' => '1',
- 'scope' => '1,2,3',
- 'registrationUrl' => '',
- 'size' => 'medium',
- 'onlogin' => ''
- ))
- ->will($this->returnValue($expected));
- $facebookMock = $this->getMockBuilder('FOS\FacebookBundle\Facebook\FacebookSessionPersistence')
- ->disableOriginalConstructor()
- ->setMethods(array('getAppId'))
- ->getMock();
- $routing = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')
- ->disableOriginalConstructor()
- ->getMock();
- $facebookMock->expects($this->any())
- ->method('getAppId');
- $helper = new FacebookHelper($templating, $facebookMock, $routing, true, 'en_US', array(1,2,3) );
- $this->assertSame($expected, $helper->loginButton(array('label' => 'testLabel')));
- }
- }