PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

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