Completed
Push — master ( 3d7536...3ced6b )
by Marcin
02:56
created

DateTimeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 28
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPnaValidShort() 0 16 1
A testDateInvalid() 0 4 1
1
<?php
2
/**
3
 * Validator
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 *
12
 * @author Marcin Pudełek <[email protected]>
13
 */
14
15
namespace mrcnpdlk\Validator;
16
17
18
use mrcnpdlk\Validator\Types\DateTime;
19
20
class DateTimeTest extends TestCase
21
{
22
    public function testPnaValidShort()
23
    {
24
        $this->assertTrue(DateTime::isValid('2017-10-01', false));
25
        $res   = new DateTime('2017-10-01');
26
        $this->assertEquals('2017-10-01 00:00:00', $res->get());
27
28
        $res   = new DateTime('2017-10-01 22:15:45');
29
        $this->assertEquals('2017-10-01 22:15:45', $res->get());
30
        $this->assertEquals('2017', $res->getYear());
31
        $this->assertEquals('10', $res->getMonth());
32
        $this->assertEquals('01', $res->getDay());
33
        $this->assertEquals('22:15:45', $res->getTime());
34
        $this->assertEquals('22', $res->getHour());
35
        $this->assertEquals('15', $res->getMinute());
36
        $this->assertEquals('45', $res->getSecond());
37
    }
38
39
    /**
40
     * @expectedException \mrcnpdlk\Validator\Exception
41
     */
42
    public function testDateInvalid()
43
    {
44
        DateTime::isValid('2017-10-01 00:01:78', true);
45
    }
46
47
}
48