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\PiwikBundle\Tests\Block\Service; |
13
|
|
|
|
14
|
|
|
use Core23\PiwikBundle\Block\Service\PiwikTrackerBlockService; |
15
|
|
|
use Sonata\BlockBundle\Block\BlockContext; |
16
|
|
|
use Sonata\BlockBundle\Model\Block; |
17
|
|
|
use Sonata\BlockBundle\Model\BlockInterface; |
18
|
|
|
use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase; |
19
|
|
|
|
20
|
|
|
final class PiwikTrackerBlockServiceTest extends AbstractBlockServiceTestCase |
21
|
|
|
{ |
22
|
|
|
public function testExecute(): void |
23
|
|
|
{ |
24
|
|
|
$block = new Block(); |
25
|
|
|
|
26
|
|
|
$blockContext = new BlockContext($block, [ |
27
|
|
|
'host' => null, |
28
|
|
|
'site' => null, |
29
|
|
|
'domaintitle' => false, |
30
|
|
|
'donottrack' => false, |
31
|
|
|
'nocookies' => false, |
32
|
|
|
'template' => '@Core23Piwik/Block/block_piwik_tracker.html.twig', |
33
|
|
|
]); |
34
|
|
|
|
35
|
|
|
$blockService = new PiwikTrackerBlockService('block.service', $this->templating); |
36
|
|
|
$blockService->execute($blockContext); |
37
|
|
|
|
38
|
|
|
$this->assertSame('@Core23Piwik/Block/block_piwik_tracker.html.twig', $this->templating->view); |
39
|
|
|
|
40
|
|
|
$this->assertSame($blockContext, $this->templating->parameters['context']); |
41
|
|
|
$this->assertInternalType('array', $this->templating->parameters['settings']); |
42
|
|
|
$this->assertInstanceOf(BlockInterface::class, $this->templating->parameters['block']); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testDefaultSettings(): void |
46
|
|
|
{ |
47
|
|
|
$blockService = new PiwikTrackerBlockService('block.service', $this->templating); |
48
|
|
|
$blockContext = $this->getBlockContext($blockService); |
49
|
|
|
|
50
|
|
|
$this->assertSettings([ |
51
|
|
|
'host' => null, |
52
|
|
|
'site' => null, |
53
|
|
|
'domaintitle' => false, |
54
|
|
|
'donottrack' => false, |
55
|
|
|
'nocookies' => false, |
56
|
|
|
'template' => '@Core23Piwik/Block/block_piwik_tracker.html.twig', |
57
|
|
|
], $blockContext); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|