Completed
Push — master ( 5052b0...8431a9 )
by Gabriel
04:18
created

HasDecoratorsTraitTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 13
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAddDecorator() 0 10 1
1
<?php
2
3
namespace Nip\Form\Tests\Elements\Traits;
4
5
use Nip\Form\Decorator\Elements\Text;
6
use Nip\Form\Form;
7
use Nip\Form\Tests\AbstractTest;
8
9
/**
10
 * Class HasDecoratorsTraitTest
11
 * @package Nip\Form\Tests\Elements\Traits
12
 */
13
class HasDecoratorsTraitTest extends AbstractTest
14
{
15
    public function testAddDecorator()
16
    {
17
        $element = new \Nip_Form_Element_Input(new Form());
18
        $decorator = $element->addDecorator('text', 'element', 'currency');
0 ignored issues
show
Documentation introduced by
'currency' is of type string, but the function expects a boolean.

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...
19
20
        self::assertSame($decorator, $element->getDecorator('currency'), 'element');
21
22
        $getDecorator = $element->getDecorator('currency');
23
        self::assertInstanceOf(Text::class, $getDecorator);
24
    }
25
}
26