Completed
Push — 2.x-dev-kit ( 971030 )
by
unknown
07:52
created

FacebookShareButtonBlockServiceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
c 3
b 0
f 0
lcom 0
cbo 6
dl 0
loc 39
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testService() 0 36 2
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\SeoBundle\Tests\Block\Social;
13
14
use Sonata\BlockBundle\Block\BlockContext;
15
use Sonata\BlockBundle\Model\Block;
16
use Sonata\BlockBundle\Tests\Block\Service\FakeTemplating;
17
use Sonata\BlockBundle\Util\OptionsResolver;
18
use Sonata\SeoBundle\Block\Social\FacebookShareButtonBlockService;
19
use Sonata\SeoBundle\Tests\Block\BaseBlockTest;
20
21
class FacebookShareButtonBlockServiceTest extends BaseBlockTest
22
{
23
    public function testService()
24
    {
25
        if (!$this->checkBlockBundle()) {
26
            $this->markTestSkipped('Sonata BlockBundle is not installed.');
27
28
            return;
29
        }
30
31
        $templating = new FakeTemplating();
32
        $service = new FacebookShareButtonBlockService('sonata.block.service.facebook.share_button', $templating);
33
34
        $block = new Block();
35
        $block->setType('core.text');
36
        $block->setSettings(array(
37
            'url' => 'url_setting',
38
            'width' => 'width_setting',
39
            'layout' => 'layout_setting',
40
        ));
41
42
        $optionResolver = new OptionsResolver();
43
        $service->setDefaultSettings($optionResolver);
44
45
        $blockContext = new BlockContext($block, $optionResolver->resolve($block->getSettings()));
46
47
        $formMapper = $this->getMock('Sonata\\AdminBundle\\Form\\FormMapper', array(), array(), '', false);
48
        $formMapper->expects($this->exactly(2))->method('add');
49
50
        $service->buildCreateForm($formMapper, $block);
51
        $service->buildEditForm($formMapper, $block);
52
53
        $service->execute($blockContext);
54
55
        $this->assertEquals('url_setting', $templating->parameters['settings']['url']);
56
        $this->assertEquals('width_setting', $templating->parameters['settings']['width']);
57
        $this->assertEquals('layout_setting', $templating->parameters['settings']['layout']);
58
    }
59
}
60