Completed
Push — master ( 4c5b82...ece630 )
by Jeroen
19s
created

SearchViewRendererTest::testRemoveHtml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Kunstmaan\NodeSearchBundle\Tests\unit\Services;
4
5
use Kunstmaan\NodeSearchBundle\Helper\IndexablePagePartsService;
6
use Kunstmaan\NodeSearchBundle\Services\SearchViewRenderer;
7
use PHPUnit\Framework\TestCase;
8
use Symfony\Component\HttpFoundation\RequestStack;
9
use Twig\Environment;
10
11
class SearchViewRendererTest extends TestCase
12
{
13
    /**
14
     * @dataProvider htmlDataProvider
15
     */
16
    public function testRemoveHtml($input, $exptectedOutput)
17
    {
18
        $searchViewRenderer = new SearchViewRenderer(
19
            $this->createMock(Environment::class),
0 ignored issues
show
Documentation introduced by
$this->createMock(\Twig\Environment::class) is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Twig\Environment>.

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...
20
            $this->createMock(IndexablePagePartsService::class),
0 ignored issues
show
Documentation introduced by
$this->createMock(\Kunst...agePartsService::class) is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\NodeSea...exablePagePartsService>.

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...
21
            new RequestStack()
22
        );
23
24
        self::assertEquals($exptectedOutput, $searchViewRenderer->removeHtml($input));
25
    }
26
27
    public function htmlDataProvider()
28
    {
29
        return [
30
            ['le élève est ûn garçön', 'le élève est ûn garçön'],
31
            ['Hello world!', 'Hello world!'],
32
            ['<html><body><p>Hello world!</p></body></html>', 'Hello world!'],
33
            ['<div><b>le élève est ûn garçön</b></div>', 'le élève est ûn garçön'],
34
        ];
35
    }
36
}
37