CreateFromDateTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateFromDateWithDefaults() 0 5 1
A testCreateFromDate() 0 5 1
A testCreateFromDateWithYear() 0 5 1
A testCreateFromDateWithMonth() 0 5 1
A testCreateFromDateWithDay() 0 5 1
A testCreateFromDateWithTimezone() 0 6 1
A testCreateFromDateWithDateTimeZone() 0 6 1
1
<?php
2
3
namespace HMLB\Date\Tests\Date;
4
5
/*
6
 * This file is part of the Date package.
7
 *
8
 * (c) Hugues Maignol <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use HMLB\Date\Date;
15
use HMLB\Date\Tests\AbstractTestCase;
16
17
class CreateFromDateTest extends AbstractTestCase
18
{
19
    public function testCreateFromDateWithDefaults()
20
    {
21
        $d = Date::createFromDate();
22
        $this->assertSame($d->getTimestamp(), Date::create(null, null, null, null, null, null)->getTimestamp());
23
    }
24
25
    public function testCreateFromDate()
26
    {
27
        $d = Date::createFromDate(1975, 5, 21);
28
        $this->assertDate($d, 1975, 5, 21);
29
    }
30
31
    public function testCreateFromDateWithYear()
32
    {
33
        $d = Date::createFromDate(1975);
34
        $this->assertSame(1975, $d->getYear());
35
    }
36
37
    public function testCreateFromDateWithMonth()
38
    {
39
        $d = Date::createFromDate(null, 5);
40
        $this->assertSame(5, $d->getMonth());
41
    }
42
43
    public function testCreateFromDateWithDay()
44
    {
45
        $d = Date::createFromDate(null, null, 21);
46
        $this->assertSame(21, $d->getDay());
47
    }
48
49
    public function testCreateFromDateWithTimezone()
50
    {
51
        $d = Date::createFromDate(1975, 5, 21, 'Europe/London');
52
        $this->assertDate($d, 1975, 5, 21);
53
        $this->assertSame('Europe/London', $d->getTimezoneName());
54
    }
55
56
    public function testCreateFromDateWithDateTimeZone()
57
    {
58
        $d = Date::createFromDate(1975, 5, 21, new \DateTimeZone('Europe/London'));
59
        $this->assertDate($d, 1975, 5, 21);
60
        $this->assertSame('Europe/London', $d->getTimezoneName());
61
    }
62
}
63