PageRenderTime 35ms CodeModel.GetById 17ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 1ms

/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
  1<?php
  2
  3/*
  4 * This file is part of the FOSFacebookBundle package.
  5 *
  6 * (c) FriendsOfSymfony <http://friendsofsymfony.github.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
 12namespace FOS\FacebookBundle\Tests\Templating\Helper;
 13
 14use FOS\FacebookBundle\Templating\Helper\FacebookHelper;
 15
 16class FacebookHelperTest extends \PHPUnit_Framework_TestCase
 17{
 18    /**
 19     * @covers FOS\FacebookBundle\Templating\Helper\FacebookHelper::initialize
 20     */
 21    public function testInitialize()
 22    {
 23        $expected = new \stdClass();
 24
 25        $templating = $this->getMockBuilder('Symfony\Component\Templating\DelegatingEngine')
 26            ->disableOriginalConstructor()
 27            ->getMock();
 28        $templating
 29            ->expects($this->once())
 30            ->method('render')
 31            ->with('FOSFacebookBundle::initialize.html.php', array(
 32                'appId'   => 123,
 33                'async'   => true,
 34                'cookie'  => false,
 35                'culture' => 'en_US',
 36                'fbAsyncInit' => '',
 37                'logging' => true,
 38                'oauth' => true,
 39                'status'  => false,
 40                'channelUrl' => '/channel.html',
 41                'xfbml'   => false,
 42            ))
 43            ->will($this->returnValue($expected));
 44
 45        $facebookMock = $this->getMockBuilder('FOS\FacebookBundle\Facebook\FacebookSessionPersistence')
 46            ->disableOriginalConstructor()
 47            ->setMethods(array('getAppId'))
 48            ->getMock();
 49
 50        $routing = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')
 51            ->disableOriginalConstructor()
 52            ->getMock();
 53        $routing
 54            ->expects($this->once())
 55            ->method('generate')
 56            ->will($this->returnValue('/channel.html'));
 57
 58        $facebookMock->expects($this->once())
 59            ->method('getAppId')
 60            ->will($this->returnValue('123'));
 61
 62        $helper = new FacebookHelper($templating, $facebookMock, $routing);
 63        $this->assertSame($expected, $helper->initialize(array('cookie' => false)));
 64    }
 65
 66    /**
 67     * @covers FOS\FacebookBundle\Templating\Helper\FacebookHelper::loginButton
 68     */
 69    public function testLoginButton()
 70    {
 71        $expected = new \stdClass();
 72
 73        $templating = $this->getMockBuilder('Symfony\Component\Templating\DelegatingEngine')
 74            ->disableOriginalConstructor()
 75            ->getMock();
 76        $templating
 77            ->expects($this->once())
 78            ->method('render')
 79            ->with('FOSFacebookBundle::loginButton.html.php', array(
 80                'autologoutlink'  => 'false',
 81                'label'           => 'testLabel',
 82                'showFaces'       => 'false',
 83                'width'           => '',
 84                'maxRows'         => '1',
 85                'scope'           => '1,2,3',
 86                'registrationUrl' => '',
 87                'size'            => 'medium',
 88                'onlogin'         => ''
 89            ))
 90            ->will($this->returnValue($expected));
 91
 92        $facebookMock = $this->getMockBuilder('FOS\FacebookBundle\Facebook\FacebookSessionPersistence')
 93            ->disableOriginalConstructor()
 94            ->setMethods(array('getAppId'))
 95            ->getMock();
 96
 97        $routing = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')
 98            ->disableOriginalConstructor()
 99            ->getMock();
100
101        $facebookMock->expects($this->any())
102            ->method('getAppId');
103
104        $helper = new FacebookHelper($templating, $facebookMock, $routing, true, 'en_US', array(1,2,3) );
105        $this->assertSame($expected, $helper->loginButton(array('label' => 'testLabel')));
106    }
107}