1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* (c) Christian Gripp <[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 Core23\ShariffBundle\Tests\Block\Service; |
13
|
|
|
|
14
|
|
|
use Core23\ShariffBundle\Block\Service\ShariffShareBlockService; |
15
|
|
|
use Sonata\AdminBundle\Form\FormMapper; |
16
|
|
|
use Sonata\BlockBundle\Block\BlockContext; |
17
|
|
|
use Sonata\BlockBundle\Model\Block; |
18
|
|
|
use Sonata\BlockBundle\Model\BlockInterface; |
19
|
|
|
use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase; |
20
|
|
|
|
21
|
|
|
final class ShariffShareBlockServiceTest extends AbstractBlockServiceTestCase |
22
|
|
|
{ |
23
|
|
|
public function testDefaultSettings(): void |
24
|
|
|
{ |
25
|
|
|
$blockService = new ShariffShareBlockService('block.service', $this->templating); |
26
|
|
|
$blockContext = $this->getBlockContext($blockService); |
27
|
|
|
|
28
|
|
|
$this->assertSettings([ |
29
|
|
|
'url' => null, |
30
|
|
|
'class' => null, |
31
|
|
|
'services' => ['twitter', 'facebook', 'googleplus'], |
32
|
|
|
'theme' => 'standard', |
33
|
|
|
'orientation' => 'horizontal', |
34
|
|
|
'flattrUser' => null, |
35
|
|
|
'flattrCategory' => null, |
36
|
|
|
'template' => '@Core23Shariff/Block/block_shariff.html.twig', |
37
|
|
|
], $blockContext); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testExecute(): void |
41
|
|
|
{ |
42
|
|
|
$block = new Block(); |
43
|
|
|
|
44
|
|
|
$blockContext = new BlockContext($block, [ |
45
|
|
|
'url' => null, |
46
|
|
|
'class' => null, |
47
|
|
|
'services' => ['twitter', 'facebook', 'googleplus'], |
48
|
|
|
'theme' => 'standard', |
49
|
|
|
'orientation' => 'horizontal', |
50
|
|
|
'flattrUser' => null, |
51
|
|
|
'flattrCategory' => null, |
52
|
|
|
'template' => '@Core23Shariff/Block/block_shariff.html.twig', |
53
|
|
|
]); |
54
|
|
|
|
55
|
|
|
$blockService = new ShariffShareBlockService('block.service', $this->templating); |
56
|
|
|
$blockService->execute($blockContext); |
57
|
|
|
|
58
|
|
|
$this->assertSame('@Core23Shariff/Block/block_shariff.html.twig', $this->templating->view); |
59
|
|
|
|
60
|
|
|
$this->assertSame($blockContext, $this->templating->parameters['context']); |
61
|
|
|
$this->assertInternalType('array', $this->templating->parameters['settings']); |
62
|
|
|
$this->assertInstanceOf(BlockInterface::class, $this->templating->parameters['block']); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testBuildEditForm(): void |
66
|
|
|
{ |
67
|
|
|
$blockService = new ShariffShareBlockService('block.service', $this->templating); |
68
|
|
|
|
69
|
|
|
$block = new Block(); |
70
|
|
|
|
71
|
|
|
$formMapper = $this->createMock(FormMapper::class); |
72
|
|
|
$formMapper->expects($this->once())->method('add'); |
73
|
|
|
|
74
|
|
|
$blockService->buildEditForm($formMapper, $block); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|