GettersTest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

9 Methods

Rating   Name   Duplication   Size   Complexity  
A testGettersThrowExceptionOnUnknownGetter() 0 4 1
A testYearsGetter() 0 5 1
A testMonthsGetter() 0 5 1
A testWeeksGetter() 0 5 1
A testDayzExcludingWeeksGetter() 0 6 1
A testDayzGetter() 0 5 1
A testHoursGetter() 0 5 1
A testMinutesGetter() 0 5 1
A testSecondsGetter() 0 5 1
1
<?php
2
3
namespace HMLB\Date\Tests\Interval;
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\Interval;
15
use HMLB\Date\Tests\AbstractTestCase;
16
17
class GettersTest extends AbstractTestCase
18
{
19
    /**
20
     * @expectedException \InvalidArgumentException
21
     */
22
    public function testGettersThrowExceptionOnUnknownGetter()
23
    {
24
        Interval::year()->sdfsdfss;
25
    }
26
27
    public function testYearsGetter()
28
    {
29
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
30
        $this->assertSame(4, $d->years);
31
    }
32
33
    public function testMonthsGetter()
34
    {
35
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
36
        $this->assertSame(5, $d->months);
37
    }
38
39
    public function testWeeksGetter()
40
    {
41
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
42
        $this->assertSame(6, $d->weeks);
43
    }
44
45
    public function testDayzExcludingWeeksGetter()
46
    {
47
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
48
        $this->assertSame(5, $d->daysExcludeWeeks);
49
        $this->assertSame(5, $d->dayzExcludeWeeks);
50
    }
51
52
    public function testDayzGetter()
53
    {
54
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
55
        $this->assertSame(6 * 7 + 5, $d->dayz);
56
    }
57
58
    public function testHoursGetter()
59
    {
60
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
61
        $this->assertSame(8, $d->hours);
62
    }
63
64
    public function testMinutesGetter()
65
    {
66
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
67
        $this->assertSame(9, $d->minutes);
68
    }
69
70
    public function testSecondsGetter()
71
    {
72
        $d = Interval::create(4, 5, 6, 5, 8, 9, 10);
73
        $this->assertSame(10, $d->seconds);
74
    }
75
}
76