FacebookShareButtonBlockServiceTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 5
dl 0
loc 41
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testService() 0 38 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\SeoBundle\Tests\Block\Social;
15
16
use Sonata\BlockBundle\Block\BlockContext;
17
use Sonata\BlockBundle\Form\Mapper\FormMapper;
18
use Sonata\BlockBundle\Model\Block;
19
use Sonata\BlockBundle\Test\BlockServiceTestCase;
20
use Sonata\SeoBundle\Block\Social\FacebookShareButtonBlockService;
21
use Symfony\Component\OptionsResolver\OptionsResolver;
22
23
final class FacebookShareButtonBlockServiceTest extends BlockServiceTestCase
24
{
25
    public function testService(): void
26
    {
27
        $service = new FacebookShareButtonBlockService(
28
            $this->twig
29
        );
30
31
        $block = new Block();
32
        $block->setType('core.text');
33
        $block->setSettings([
34
            'url' => 'url_setting',
35
            'width' => 'width_setting',
36
            'layout' => 'layout_setting',
37
        ]);
38
39
        $optionResolver = new OptionsResolver();
40
        $service->configureSettings($optionResolver);
41
42
        $blockContext = new BlockContext($block, $optionResolver->resolve($block->getSettings()));
43
44
        $formMapper = $this->createMock(FormMapper::class, [], [], '', false);
45
        $formMapper->expects($this->exactly(2))->method('add');
46
47
        $service->configureCreateForm($formMapper, $block);
48
        $service->configureEditForm($formMapper, $block);
49
50
        $this->twig->expects($this->once())->method('render')
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<Twig\Environment>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
            ->with('@SonataSeo/Block/block_facebook_share_button.html.twig', [
52
               'block' => $block,
53
               'settings' => [
54
                   'url' => 'url_setting',
55
                   'width' => 'width_setting',
56
                   'layout' => 'layout_setting',
57
                   'template' => '@SonataSeo/Block/block_facebook_share_button.html.twig',
58
               ],
59
            ]);
60
61
        $service->execute($blockContext);
62
    }
63
}
64