SecondsTest   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 69
rs 10
wmc 12

6 Methods

Rating   Name   Duplication   Size   Complexity  
A inDaysCalculatesValue() 0 5 2
A inMonthsCalculatesValue() 0 5 2
A inMinutesCalculatesValue() 0 4 2
A inWeeksCalculatesValue() 0 5 2
A inHoursCalculatesValue() 0 4 2
A inYearsCalculatesValue() 0 5 2
1
<?php
2
3
namespace SubjectivePHPTest\Durations;
4
5
use SubjectivePHP\Durations\Seconds;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @coversDefaultClass \SubjectivePHP\Durations\Seconds
10
 */
11
final class SecondsTest extends TestCase
12
{
13
    /**
14
     * @test
15
     * @covers ::inMinutes
16
     */
17
    public function inMinutesCalculatesValue()
18
    {
19
        for ($i = 0; $i < 60; $i++) {
20
            $this->assertSame(60 * $i, Seconds::inMinutes($i));
21
        }
22
    }
23
24
    /**
25
     * @test
26
     * @covers ::inHours
27
     */
28
    public function inHoursCalculatesValue()
29
    {
30
        for ($i = 0; $i < 60; $i++) {
31
            $this->assertSame(60 * 60 * $i, Seconds::inHours($i));
32
        }
33
    }
34
35
    /**
36
     * @test
37
     * @covers ::inDays
38
     */
39
    public function inDaysCalculatesValue()
40
    {
41
        for ($i = 0; $i < 60; $i++) {
42
            $expected = 60 * 60 * 24 * $i;
43
            $this->assertSame($expected, Seconds::inDays($i));
44
        }
45
    }
46
47
    /**
48
     * @test
49
     * @covers ::inWeeks
50
     */
51
    public function inWeeksCalculatesValue()
52
    {
53
        for ($i = 0; $i < 60; $i++) {
54
            $expected = 60 * 60 * 24 * 7 * $i;
55
            $this->assertSame($expected, Seconds::inWeeks($i));
56
        }
57
    }
58
59
    /**
60
     * @test
61
     * @covers ::inMonths
62
     */
63
    public function inMonthsCalculatesValue()
64
    {
65
        for ($i = 0; $i < 60; $i++) {
66
            $expected = 60 * 60 * 24 * 30 * $i;
67
            $this->assertSame($expected, Seconds::inMonths($i));
68
        }
69
    }
70
71
    /**
72
     * @test
73
     * @covers ::inYears
74
     */
75
    public function inYearsCalculatesValue()
76
    {
77
        for ($i = 0; $i < 60; $i++) {
78
            $expected = 60 * 60 * 24 * 365 * $i;
79
            $this->assertSame($expected, Seconds::inYears($i));
80
        }
81
    }
82
}
83