-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathFormInputTest.php
More file actions
53 lines (44 loc) · 1.33 KB
/
Copy pathFormInputTest.php
File metadata and controls
53 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Tests\PHPCensor\Form;
use PHPCensor\Form\DataTransformer\Yaml;
use PHPCensor\Form\Input;
use PHPUnit\Framework\TestCase;
class FormInputTest extends TestCase
{
/** @var Input $inputElement */
private $inputElement;
protected function setUp(): void
{
parent::setUp();
$this->inputElement = Input::create('test', 'Test');
}
protected function tearDown(): void
{
$this->inputElement = null;
parent::tearDown();
}
public function testValidatorSetterGetterSuccess()
{
$validator = function ($value) {
echo $value;
};
$this->inputElement->setValidator($validator);
$this->assertEquals($validator, $this->inputElement->getValidator());
}
public function testValidatorSetFail()
{
$this->inputElement->setValidator(5);
$this->assertNull($this->inputElement->getValidator());
}
public function testGetValue()
{
$this->inputElement->setValue(5);
$this->assertEquals(5, $this->inputElement->getValue());
}
public function testGetValueWithDatatransformer()
{
$this->inputElement->setDataTransformator(new Yaml());
$this->inputElement->setValue("key\t=>\tvalue");
$this->assertEquals('key => value', $this->inputElement->getValue());
}
}