GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e2b677...ea368a )
by Christian
01:30
created

PageFeedBlockServiceTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\FacebookBundle\Tests\Block\Service;
11
12
use Core23\FacebookBundle\Block\Service\PageFeedBlockService;
13
use Facebook\Authentication\AccessToken;
14
use Facebook\Facebook;
15
use Facebook\FacebookApp;
16
use Facebook\FacebookResponse;
17
use Facebook\GraphNodes\GraphEdge;
18
use Sonata\BlockBundle\Block\BlockContext;
19
use Sonata\BlockBundle\Model\Block;
20
use Sonata\BlockBundle\Model\BlockInterface;
21
use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase;
22
23
class PageFeedBlockServiceTest extends AbstractBlockServiceTestCase
24
{
25
    /**
26
     * @var \PHPUnit_Framework_MockObject_MockObject|Facebook
27
     */
28
    private $facebook;
29
30
    protected function setUp()
31
    {
32
        parent::setUp();
33
34
        $this->facebook = $this->createMock(Facebook::class);
35
    }
36
37
    public function testExecute()
38
    {
39
        $token = $this->createMock(AccessToken::class);
40
41
        $app = $this->createMock(FacebookApp::class);
42
        $app->expects($this->once())->method('getAccessToken')
43
            ->will($this->returnValue($token));
44
45
        $this->facebook->expects($this->once())->method('getApp')
46
            ->will($this->returnValue($app));
47
48
        $feedResponse = array(
49
            array('foo' => 'bar'),
50
        );
51
52
        $edge = $this->createMock(GraphEdge::class);
53
        $edge->expects($this->once())->method('asArray')
54
            ->will($this->returnValue($feedResponse));
55
56
        $response = $this->createMock(FacebookResponse::class);
57
        $response->expects($this->once())->method('getGraphEdge')
58
            ->will($this->returnValue($edge));
59
60
        $this->facebook->method('get')
61
            ->with($this->equalTo('/0815/feed?fields=type,message,description,permalink_url,picture,created_time'), $this->equalTo($token))
62
            ->will($this->returnValue($response));
63
64
        $block = new Block();
65
66
        $blockContext = new BlockContext($block, array(
67
            'title'    => 'Facebook Timeline',
68
            'template' => 'Core23FacebookBundle:Block:block_page_feed.html.twig',
69
            'id'       => '0815',
70
            'fields'   => 'type,message,description,permalink_url,picture,created_time',
71
        ));
72
73
        $blockService = new PageFeedBlockService('block.service', $this->templating, $this->facebook);
74
        $blockService->execute($blockContext);
75
76
        $this->assertSame('Core23FacebookBundle:Block:block_page_feed.html.twig', $this->templating->view);
77
78
        $this->assertSame($blockContext, $this->templating->parameters['context']);
79
        $this->assertInternalType('array', $this->templating->parameters['settings']);
80
        $this->assertInstanceOf(BlockInterface::class, $this->templating->parameters['block']);
81
82
        $this->assertSame($feedResponse, $this->templating->parameters['feed']);
83
    }
84
85
    public function testDefaultSettings()
86
    {
87
        $blockService = new PageFeedBlockService('block.service', $this->templating, $this->facebook);
88
        $blockContext = $this->getBlockContext($blockService);
89
90
        $this->assertSettings(array(
91
            'title'    => 'Facebook Timeline',
92
            'id'       => null,
93
            'limit'    => 10,
94
            'class'    => '',
95
            'fields'   => 'type,message,description,permalink_url,picture,created_time',
96
            'template' => 'Core23FacebookBundle:Block:block_page_feed.html.twig',
97
        ), $blockContext);
98
    }
99
}
100