Completed
Push — develop ( 72aae6...d42c3f )
by Freddie
02:15
created

InputTest::getTypeNameOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 16
rs 9.7998
1
<?php
2
3
namespace FlexPHP\Inputs\Tests\Unit;
4
5
use FlexPHP\Inputs\Input;
6
use FlexPHP\Inputs\Tests\TestCase;
7
use InvalidArgumentException;
8
9
class InputTest extends TestCase
10
{
11
    public function testItCreateTypeNotValidThrownException(): void
12
    {
13
        $this->expectException(InvalidArgumentException::class);
14
        $this->expectExceptionMessage('supported');
15
16
        Input::create('unknow', 'foo');
17
    }
18
19
    public function testItMethodTypeNotValidThrownException(): void
20
    {
21
        $this->expectException(InvalidArgumentException::class);
22
        $this->expectExceptionMessage('supported');
23
24
        Input::unknow('foo');
0 ignored issues
show
Bug introduced by
The method unknow() does not exist on FlexPHP\Inputs\Input. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        Input::/** @scrutinizer ignore-call */ 
25
               unknow('foo');
Loading history...
25
    }
26
27
    /**
28
     * @dataProvider getTypeNameOptions
29
     */
30
    public function testItRenderCreateText($type): void
31
    {
32
        $render = Input::create($type, 'foo');
33
34
        $this->assertEquals(<<<'T'
35
<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div>
36
T, $render);
37
    }
38
39
    public function testItRenderText(): void
40
    {
41
        $render = Input::text('foo');
0 ignored issues
show
Unused Code introduced by
The call to FlexPHP\Inputs\Input::text() has too many arguments starting with 'foo'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        /** @scrutinizer ignore-call */ 
42
        $render = Input::text('foo');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
42
43
        $this->assertEquals(<<<'T'
44
<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div>
45
T, $render);
46
    }
47
48
    public function getTypeNameOptions(): array
49
    {
50
        return [
51
            ['text'],
52
            [' text '],
53
            [' text'],
54
            ['text '],
55
            ['TEXT '],
56
            ['textType'],
57
            [' textType '],
58
            [' textType'],
59
            ['textType '],
60
            ['TextType '],
61
            ['Texttype '],
62
            ['texttype '],
63
            ['TEXTTYPE '],
64
        ];
65
    }
66
}
67