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

FacebookSendButtonBlockServiceTest::testService()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 38
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 38
rs 8.8571
cc 2
eloc 25
nc 2
nop 0
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\FacebookSendButtonBlockService;
19
use Sonata\SeoBundle\Tests\Block\BaseBlockTest;
20
21
class FacebookSendButtonBlockServiceTest 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 FacebookSendButtonBlockService('sonata.block.service.facebook.send_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
            'height' => 'height_setting',
40
            'colorscheme' => 'colorscheme_setting',
41
        ));
42
43
        $optionResolver = new OptionsResolver();
44
        $service->setDefaultSettings($optionResolver);
45
46
        $blockContext = new BlockContext($block, $optionResolver->resolve($block->getSettings()));
47
48
        $formMapper = $this->getMock('Sonata\\AdminBundle\\Form\\FormMapper', array(), array(), '', false);
49
        $formMapper->expects($this->exactly(2))->method('add');
50
51
        $service->buildCreateForm($formMapper, $block);
52
        $service->buildEditForm($formMapper, $block);
53
54
        $service->execute($blockContext);
55
56
        $this->assertEquals('url_setting', $templating->parameters['settings']['url']);
57
        $this->assertEquals('width_setting', $templating->parameters['settings']['width']);
58
        $this->assertEquals('height_setting', $templating->parameters['settings']['height']);
59
        $this->assertEquals('colorscheme_setting', $templating->parameters['settings']['colorscheme']);
60
    }
61
}
62