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

GalleryBlockServiceTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
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\Test\AbstractBlockServiceTestCase;
15
use Sonata\MediaBundle\Block\GalleryBlockService;
16
17
class GalleryBlockServiceTest extends AbstractBlockServiceTestCase
18
{
19
    protected $container;
20
    private $galleryManager;
21
    private $blockService;
22
23
    protected function setUp()
24
    {
25
        parent::setUp();
26
27
        $this->container = $this->prophesize('Symfony\Component\DependencyInjection\ContainerInterface');
28
        $this->galleryManager = $this->prophesize('Sonata\MediaBundle\Model\GalleryManagerInterface');
29
30
        $this->blockService = new GalleryBlockService(
31
            'block.service',
32
            $this->templating,
33
            $this->container->reveal(),
34
            $this->galleryManager->reveal()
35
        );
36
    }
37
38
    public function testExecute()
39
    {
40
        $block = $this->prophesize('Sonata\BlockBundle\Model\Block');
41
        $gallery = $this->prophesize('Sonata\MediaBundle\Model\GalleryInterface');
42
        $blockContext = $this->prophesize('Sonata\BlockBundle\Block\BlockContext');
43
44
        $blockContext->getBlock()->willReturn($block->reveal());
45
        $blockContext->getSettings()->willReturn(array('settings'));
46
        $blockContext->getTemplate()->willReturn('template');
47
        $block->getSetting('galleryId')->willReturn($gallery->reveal());
48
        $gallery->getGalleryItems()->willReturn(array());
49
50
        $this->blockService->execute($blockContext->reveal());
51
52
        $this->assertSame('template', $this->templating->view);
53
        $this->assertInternalType('array', $this->templating->parameters['settings']);
54
        $this->assertInternalType('array', $this->templating->parameters['elements']);
55
        $this->assertSame($gallery->reveal(), $this->templating->parameters['gallery']);
56
        $this->assertSame($block->reveal(), $this->templating->parameters['block']);
57
    }
58
59
    public function testDefaultSettings()
60
    {
61
        $blockContext = $this->getBlockContext($this->blockService);
62
63
        $this->assertSettings(array(
64
            'attr' => array(),
65
            'context' => false,
66
            'extra_cache_keys' => array(),
67
            'format' => false,
68
            'gallery' => false,
69
            'galleryId' => null,
70
            'pauseTime' => 3000,
71
            'startPaused' => false,
72
            'template' => 'SonataMediaBundle:Block:block_gallery.html.twig',
73
            'title' => false,
74
            'ttl' => 0,
75
            'use_cache' => true,
76
        ), $blockContext);
77
    }
78
}
79