flexphp /
flex-inputs
| 1 | <?php declare(strict_types=1); |
||
| 2 | /* |
||
| 3 | * This file is part of FlexPHP. |
||
| 4 | * |
||
| 5 | * (c) Freddie Gar <[email protected]> |
||
| 6 | * |
||
| 7 | * For the full copyright and license information, please view the LICENSE |
||
| 8 | * file that was distributed with this source code. |
||
| 9 | */ |
||
| 10 | namespace FlexPHP\Inputs\Tests\Unit; |
||
| 11 | |||
| 12 | use FlexPHP\Inputs\Input; |
||
| 13 | use FlexPHP\Inputs\Tests\TestCase; |
||
| 14 | use InvalidArgumentException; |
||
| 15 | |||
| 16 | class InputTest extends TestCase |
||
| 17 | { |
||
| 18 | public function testItCreateTypeNotValidThrownException(): void |
||
| 19 | { |
||
| 20 | $this->expectException(InvalidArgumentException::class); |
||
| 21 | $this->expectExceptionMessage('supported'); |
||
| 22 | |||
| 23 | Input::create('unknow', 'foo'); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function testItMethodTypeNotValidThrownException(): void |
||
| 27 | { |
||
| 28 | $this->expectException(InvalidArgumentException::class); |
||
| 29 | $this->expectExceptionMessage('supported'); |
||
| 30 | |||
| 31 | Input::unknow('foo'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @dataProvider getTypeNameOptions |
||
| 36 | * |
||
| 37 | * @param mixed $type |
||
| 38 | */ |
||
| 39 | public function testItRenderCreateText($type): void |
||
| 40 | { |
||
| 41 | $render = Input::create($type, '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 |
||
| 46 | , $render); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function testItRenderMethodType(): void |
||
| 50 | { |
||
| 51 | $render = Input::text('foo'); |
||
| 52 | |||
| 53 | $this->assertEquals(<<<T |
||
| 54 | <div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
||
| 55 | T |
||
| 56 | , $render); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function testItRenderMethodForm(): void |
||
| 60 | { |
||
| 61 | $render = Input::form([]); |
||
| 62 | |||
| 63 | $this->assertEquals(<<<T |
||
| 64 | <form name="form" method="post"> |
||
| 65 | </form> |
||
| 66 | T |
||
| 67 | , $render); |
||
| 68 | } |
||
| 69 | |||
| 70 | public function getTypeNameOptions(): array |
||
| 71 | { |
||
| 72 | return [ |
||
| 73 | ['text'], |
||
| 74 | [' text '], |
||
| 75 | [' text'], |
||
| 76 | ['text '], |
||
| 77 | ['TEXT '], |
||
| 78 | ['textType'], |
||
| 79 | [' textType '], |
||
| 80 | [' textType'], |
||
| 81 | ['textType '], |
||
| 82 | ['TextType '], |
||
| 83 | ['Texttype '], |
||
| 84 | ['texttype '], |
||
| 85 | ['TEXTTYPE '], |
||
| 86 | ]; |
||
| 87 | } |
||
| 88 | } |
||
| 89 |