Completed
Push — develop ( ac22da...87b1c9 )
by Freddie
02:51
created

InputTest::testItRenderMethodForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 1
b 0
f 0
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 testItRenderMethodType(): void
40
    {
41
        $render = Input::text('foo');
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 testItRenderMethodForm(): void
49
    {
50
        $render = Input::form([]);
51
52
        $this->assertEquals(<<<'T'
53
<form name="form" method="post">
54
</form>
55
T, $render);
56
    }
57
58
    public function getTypeNameOptions(): array
59
    {
60
        return [
61
            ['text'],
62
            [' text '],
63
            [' text'],
64
            ['text '],
65
            ['TEXT '],
66
            ['textType'],
67
            [' textType '],
68
            [' textType'],
69
            ['textType '],
70
            ['TextType '],
71
            ['Texttype '],
72
            ['texttype '],
73
            ['TEXTTYPE '],
74
        ];
75
    }
76
}
77