1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\MediaBundle\Tests\Block; |
15
|
|
|
|
16
|
|
|
use Sonata\BlockBundle\Block\BlockContext; |
17
|
|
|
use Sonata\BlockBundle\Model\Block; |
18
|
|
|
use Sonata\BlockBundle\Test\BlockServiceTestCase; |
19
|
|
|
use Sonata\MediaBundle\Block\GalleryBlockService; |
20
|
|
|
use Sonata\MediaBundle\Model\GalleryInterface; |
21
|
|
|
use Sonata\MediaBundle\Model\GalleryManagerInterface; |
22
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
23
|
|
|
|
24
|
|
|
class GalleryBlockServiceTest extends BlockServiceTestCase |
25
|
|
|
{ |
26
|
|
|
protected $container; |
27
|
|
|
|
28
|
|
|
private $galleryManager; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var GalleryBlockService |
32
|
|
|
*/ |
33
|
|
|
private $blockService; |
34
|
|
|
|
35
|
|
|
protected function setUp(): void |
36
|
|
|
{ |
37
|
|
|
parent::setUp(); |
38
|
|
|
|
39
|
|
|
$this->container = $this->prophesize(ContainerInterface::class); |
40
|
|
|
$this->galleryManager = $this->prophesize(GalleryManagerInterface::class); |
41
|
|
|
|
42
|
|
|
$this->blockService = new GalleryBlockService( |
43
|
|
|
$this->twig, |
44
|
|
|
null, |
45
|
|
|
$this->container->reveal(), |
46
|
|
|
$this->galleryManager->reveal() |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testExecute(): void |
51
|
|
|
{ |
52
|
|
|
$block = $this->prophesize(Block::class); |
53
|
|
|
$gallery = $this->prophesize(GalleryInterface::class); |
54
|
|
|
$blockContext = $this->prophesize(BlockContext::class); |
55
|
|
|
|
56
|
|
|
$blockContext->getBlock()->willReturn($block->reveal()); |
57
|
|
|
$blockContext->getSettings()->willReturn(['settings']); |
58
|
|
|
$blockContext->getTemplate()->willReturn('template'); |
59
|
|
|
$block->getSetting('galleryId')->willReturn($gallery->reveal()); |
60
|
|
|
$gallery->getGalleryItems()->willReturn([]); |
61
|
|
|
|
62
|
|
|
$this->twig |
|
|
|
|
63
|
|
|
->expects($this->once()) |
64
|
|
|
->method('render') |
65
|
|
|
->with('template', [ |
66
|
|
|
'gallery' => $gallery->reveal(), |
67
|
|
|
'block' => $block->reveal(), |
68
|
|
|
'elements' => [], |
69
|
|
|
'settings' => ['settings'], |
70
|
|
|
]); |
71
|
|
|
|
72
|
|
|
$this->blockService->execute($blockContext->reveal()); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testDefaultSettings(): void |
76
|
|
|
{ |
77
|
|
|
$blockContext = $this->getBlockContext($this->blockService); |
78
|
|
|
|
79
|
|
|
$this->assertSettings([ |
80
|
|
|
'attr' => [], |
81
|
|
|
'context' => false, |
82
|
|
|
'extra_cache_keys' => [], |
83
|
|
|
'format' => false, |
84
|
|
|
'gallery' => false, |
85
|
|
|
'galleryId' => null, |
86
|
|
|
'pauseTime' => 3000, |
87
|
|
|
'startPaused' => false, |
88
|
|
|
'template' => '@SonataMedia/Block/block_gallery.html.twig', |
89
|
|
|
'title' => null, |
90
|
|
|
'translation_domain' => null, |
91
|
|
|
'icon' => null, |
92
|
|
|
'class' => null, |
93
|
|
|
'ttl' => 0, |
94
|
|
|
'use_cache' => true, |
95
|
|
|
], $blockContext); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
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.