GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 904293...bfb6d8 )
by Christian
13:48
created

testGetBlockMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\MatomoBundle\Tests\Block\Service;
13
14
use Core23\MatomoBundle\Block\Service\MatomoTrackerBlockService;
15
use Sonata\AdminBundle\Form\FormMapper;
16
use Sonata\BlockBundle\Block\BlockContext;
17
use Sonata\BlockBundle\Model\Block;
18
use Sonata\BlockBundle\Model\BlockInterface;
19
use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase;
20
21
final class MatomoTrackerBlockServiceTest extends AbstractBlockServiceTestCase
22
{
23
    public function testExecute(): void
24
    {
25
        $block = new Block();
26
27
        $blockContext = new BlockContext($block, [
28
            'host'        => null,
29
            'site'        => null,
30
            'domaintitle' => false,
31
            'donottrack'  => false,
32
            'nocookies'   => false,
33
            'template'    => '@Core23Matomo/Block/block_matomo_tracker.html.twig',
34
        ]);
35
36
        $blockService = new MatomoTrackerBlockService('block.service', $this->templating);
37
        $blockService->execute($blockContext);
38
39
        $this->assertSame('@Core23Matomo/Block/block_matomo_tracker.html.twig', $this->templating->view);
40
41
        $this->assertSame($blockContext, $this->templating->parameters['context']);
42
        $this->assertInternalType('array', $this->templating->parameters['settings']);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
43
        $this->assertInstanceOf(BlockInterface::class, $this->templating->parameters['block']);
44
    }
45
46
    public function testDefaultSettings(): void
47
    {
48
        $blockService = new MatomoTrackerBlockService('block.service', $this->templating);
49
        $blockContext = $this->getBlockContext($blockService);
50
51
        $this->assertSettings([
52
            'host'        => null,
53
            'site'        => null,
54
            'domaintitle' => false,
55
            'donottrack'  => false,
56
            'nocookies'   => false,
57
            'template'    => '@Core23Matomo/Block/block_matomo_tracker.html.twig',
58
        ], $blockContext);
59
    }
60
61
    public function testGetBlockMetadata(): void
62
    {
63
        $blockService = new MatomoTrackerBlockService('block.service', $this->templating);
64
65
        $metadata = $blockService->getBlockMetadata('description');
66
67
        $this->assertSame('block.service', $metadata->getTitle());
68
        $this->assertSame('description', $metadata->getDescription());
69
        $this->assertNotNull($metadata->getImage());
70
        $this->assertStringStartsWith('data:image/png;base64,', $metadata->getImage() ?? '');
71
        $this->assertSame('Core23MatomoBundle', $metadata->getDomain());
72
        $this->assertSame([
73
            'class' => 'fa fa-code',
74
        ], $metadata->getOptions());
75
    }
76
77
    public function testBuildEditForm(): void
78
    {
79
        $blockService = new MatomoTrackerBlockService('block.service', $this->templating);
80
81
        $block = new Block();
82
83
        $formMapper = $this->createMock(FormMapper::class);
84
        $formMapper->expects($this->once())->method('add');
85
86
        $blockService->buildEditForm($formMapper, $block);
0 ignored issues
show
Documentation introduced by
$formMapper is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Sonata\AdminBundle\Form\FormMapper>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
87
    }
88
}
89