Passed
Push — master ( 9503f0...488e4f )
by Petr
02:34
created

DateTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 15
c 1
b 0
f 0
dl 0
loc 28
rs 10
1
<?php
2
3
namespace ControlTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_forms\Controls;
8
use kalanis\kw_forms\Exceptions\RenderException;
9
10
11
class DateTest extends CommonTestClass
12
{
13
    /**
14
     * @throws RenderException
15
     */
16
    public function testDate(): void
17
    {
18
        $input = new Controls\DatePicker();
19
        $input->set('commit', 'original', 'not to look');
20
        $this->assertEquals('<input type="text" value="" class="datepicker" id="commit" name="commit" />', $input->renderInput());
21
        $input->setValue(1333571265);
22
        $input->setDateFormat('Y-m-d H:i');
23
        $this->assertEquals('<input type="text" value="2012-04-04 20:27" class="datepicker" id="commit" name="commit" />', $input->renderInput());
24
        $input->setValue('2010-08-18 22:33');
25
        $this->assertEquals('<input type="text" value="2010-08-18 22:33" class="datepicker" id="commit" name="commit" />', $input->renderInput());
26
    }
27
28
    /**
29
     * @throws RenderException
30
     */
31
    public function testRange(): void
32
    {
33
        $input = new Range();
34
        $input->resetUniq();
35
        $input->set('myown', 'original', 'not to look');
36
        $this->assertEquals(
37
  ' <input type="text" value="" class="datepicker" id="myown_0" name="myown[]" /> '. PHP_EOL
38
. ' <input type="text" value="" class="datepicker" id="myown_1" name="myown[]" /> ', $input->renderInput());
39
    }
40
}
41
42
43
class Range extends Controls\DateRange
44
{
45
    /**
46
     * Just for discarding problems with catching ids
47
     */
48
    public function resetUniq(): void
49
    {
50
        self::$uniqid = 0;
51
    }
52
}
53