Completed
Push — master ( 8c0a67...1fafee )
by Grégoire
9s
created

GalleryListBlockServiceTest::testDefaultSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\MediaBundle\Tests\Block;
13
14
use Sonata\BlockBundle\Block\BlockContext;
15
use Sonata\BlockBundle\Model\Block;
16
use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase;
17
use Sonata\MediaBundle\Block\GalleryListBlockService;
18
use Sonata\MediaBundle\Model\GalleryManagerInterface;
19
use Sonata\MediaBundle\Provider\Pool;
20
21
class GalleryListBlockServiceTest extends AbstractBlockServiceTestCase
22
{
23
    /**
24
     * @var \PHPUnit_Framework_MockObject_MockObject|GalleryManagerInterface
25
     */
26
    protected $galleryManager;
27
28
    /**
29
     * @var \PHPUnit_Framework_MockObject_MockObject|Pool
30
     */
31
    protected $pool;
32
33
    protected function setUp()
34
    {
35
        parent::setUp();
36
37
        $this->galleryManager = $this->getMockBuilder('Sonata\MediaBundle\Model\GalleryManagerInterface')->getMock();
38
        $this->pool = $this->getMockBuilder('Sonata\MediaBundle\Provider\Pool')->disableOriginalConstructor()->getMock();
39
    }
40
41
    public function testExecute()
42
    {
43
        $pager = $this->getMockBuilder('Sonata\DatagridBundle\Pager\PagerInterface')->getMock();
44
        $this->galleryManager->expects($this->once())->method('getPager')->will($this->returnValue($pager));
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<Sonata\MediaBundl...alleryManagerInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
46
        $block = new Block();
47
48
        $blockContext = new BlockContext($block, array(
49
            'number' => 15,
50
            'mode' => 'public',
51
            'order' => 'createdAt',
52
            'sort' => 'desc',
53
            'context' => false,
54
            'title' => 'Gallery List',
55
            'template' => 'SonataMediaBundle:Block:block_gallery_list.html.twig',
56
        ));
57
58
        $blockService = new GalleryListBlockService('block.service', $this->templating, $this->galleryManager, $this->pool);
59
        $blockService->execute($blockContext);
60
61
        $this->assertSame('SonataMediaBundle:Block:block_gallery_list.html.twig', $this->templating->view);
62
63
        $this->assertSame($blockContext, $this->templating->parameters['context']);
64
        $this->assertInternalType('array', $this->templating->parameters['settings']);
65
        $this->assertInstanceOf('Sonata\BlockBundle\Model\BlockInterface', $this->templating->parameters['block']);
66
        $this->assertSame($pager, $this->templating->parameters['pager']);
67
    }
68
69
    public function testDefaultSettings()
70
    {
71
        $blockService = new GalleryListBlockService('block.service', $this->templating, $this->galleryManager, $this->pool);
72
        $blockContext = $this->getBlockContext($blockService);
73
74
        $this->assertSettings(array(
75
            'number' => 15,
76
            'mode' => 'public',
77
            'order' => 'createdAt',
78
            'sort' => 'desc',
79
            'context' => false,
80
            'title' => 'Gallery List',
81
            'template' => 'SonataMediaBundle:Block:block_gallery_list.html.twig',
82
        ), $blockContext);
83
    }
84
}
85