Completed
Push — master ( 0406c2...d58e57 )
by Christian
04:47
created

PiwikTrackerBlockServiceTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the ni-ju-san CMS.
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\Tests\Block\AbstractBlockServiceTest;
18
use Sonata\BlockBundle\Tests\Block\Service\FakeTemplating;
19
20
class PiwikTrackerBlockServiceTest extends AbstractBlockServiceTest
21
{
22
    /**
23
     * @var FakeTemplating
24
     */
25
    protected $templating;
26
27
    protected function setUp()
28
    {
29
        parent::setUp();
30
31
        $this->templating = new FakeTemplating();
32
    }
33
34
    public function testExecute()
35
    {
36
        $block = new Block();
37
38
        $blockContext = new BlockContext($block, array(
39
            'host'        => null,
40
            'site'        => false,
41
            'domaintitle' => false,
42
            'donottrack'  => false,
43
            'nocookies'   => false,
44
            'template'    => 'Core23PiwikBundle:Block:block_piwik_tracker.html.twig',
45
        ));
46
47
        $blockService = new PiwikTrackerBlockService('block.service', $this->templating);
48
        $blockService->execute($blockContext);
49
50
        $this->assertSame('Core23PiwikBundle:Block:block_piwik_tracker.html.twig', $this->templating->view);
51
52
        $this->assertSame($blockContext, $this->templating->parameters['context']);
53
        $this->assertInternalType('array', $this->templating->parameters['settings']);
54
        $this->assertInstanceOf('Sonata\BlockBundle\Model\BlockInterface', $this->templating->parameters['block']);
55
    }
56
57
    public function testDefaultSettings()
58
    {
59
        $blockService = new PiwikTrackerBlockService('block.service', $this->templating);
60
        $blockContext = $this->getBlockContext($blockService);
61
62
        $this->assertSettings(array(
63
            'host'        => null,
64
            'site'        => false,
65
            'domaintitle' => false,
66
            'donottrack'  => false,
67
            'nocookies'   => false,
68
            'template'    => 'Core23PiwikBundle:Block:block_piwik_tracker.html.twig',
69
        ), $blockContext);
70
    }
71
}
72