Completed
Pull Request — master (#40)
by Marko
198:30 queued 133:26
created

PhpTemplateTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 51
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 22 1
A renderTemplate() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory CKEditor package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\CKEditorBundle\Tests\Template;
13
14
use FOS\CKEditorBundle\Templating\CKEditorHelper;
15
use Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper;
16
use Symfony\Component\Templating\Helper\SlotsHelper;
17
use Symfony\Component\Templating\Loader\FilesystemLoader;
18
use Symfony\Component\Templating\PhpEngine;
19
use Symfony\Component\Templating\TemplateNameParser;
20
21
/**
22
 * @author GeLo <[email protected]>
23
 */
24
class PhpTemplateTest extends AbstractTemplateTest
25
{
26
    /**
27
     * @var PhpEngine
28
     */
29
    private $phpEngine;
30
31
    /**
32
     * @var FormHelper|\PHPUnit_Framework_MockObject_MockObject
33
     */
34
    private $formHelper;
35
36
    /**
37
     * @var SlotsHelper|\PHPUnit_Framework_MockObject_MockObject
38
     */
39
    private $slotsHelper;
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    protected function setUp()
45
    {
46
        parent::setUp();
47
48
        $this->formHelper = $this->getMockBuilder(FormHelper::class)
49
            ->disableOriginalConstructor()
50
            ->getMock();
51
52
        $this->slotsHelper = $this->getMockBuilder(SlotsHelper::class)
53
            ->disableOriginalConstructor()
54
            ->getMock();
55
56
        $this->phpEngine = new PhpEngine(
57
            new TemplateNameParser(),
58
            new FilesystemLoader([__DIR__.'/../../src/Resources/views/Form/%name%']),
59
            [
0 ignored issues
show
Documentation introduced by
array('form' => $this->f...elper($this->renderer)) is of type array<string|integer,obj...ing\\CKEditorHelper>"}>, but the function expects a array<integer,object<Sym...elper\HelperInterface>>.

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...
60
                'form'  => $this->formHelper,
61
                'slots' => $this->slotsHelper,
62
                new CKEditorHelper($this->renderer),
63
            ]
64
        );
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    protected function renderTemplate(array $context = [])
71
    {
72
        return $this->phpEngine->render('ckeditor_widget.html.php', $context);
73
    }
74
}
75