TestOfDay   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 13
eloc 22
dl 0
loc 76
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A testPrevHour() 0 3 1
A testThisHour() 0 3 1
A testPrevSecond() 0 3 1
A testPrevDay_Array() 0 10 1
A testPrevMinute() 0 3 1
A testNextSecond() 0 3 1
A testThisSecond() 0 3 1
A testGetTimeStamp() 0 4 1
A testThisMinute() 0 3 1
A setUp() 0 3 1
A testNextMinute() 0 3 1
A testNextHour() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
require_once __DIR__ . '/simple_include.php';
4
require_once __DIR__ . '/calendar_include.php';
5
6
require_once __DIR__ . '/./calendar_test.php';
7
8
/**
9
 * Class TestOfDay.
10
 */
11
class TestOfDay extends TestOfCalendar
12
{
13
    /**
14
     * TestOfDay constructor.
15
     */
16
    public function __construct()
17
    {
18
        $this->UnitTestCase('Test of Day');
19
    }
20
21
    public function setUp()
22
    {
23
        $this->cal = new Calendar_Day(2003, 10, 25);
24
    }
25
26
    public function testPrevDay_Array()
27
    {
28
        $this->assertEqual([
29
                               'year'   => 2003,
30
                               'month'  => 10,
31
                               'day'    => 24,
32
                               'hour'   => 0,
33
                               'minute' => 0,
34
                               'second' => 0,
35
                           ], $this->cal->prevDay('array'));
36
    }
37
38
    public function testPrevHour()
39
    {
40
        $this->assertEqual(23, $this->cal->prevHour());
41
    }
42
43
    public function testThisHour()
44
    {
45
        $this->assertEqual(0, $this->cal->thisHour());
46
    }
47
48
    public function testNextHour()
49
    {
50
        $this->assertEqual(1, $this->cal->nextHour());
51
    }
52
53
    public function testPrevMinute()
54
    {
55
        $this->assertEqual(59, $this->cal->prevMinute());
56
    }
57
58
    public function testThisMinute()
59
    {
60
        $this->assertEqual(0, $this->cal->thisMinute());
61
    }
62
63
    public function testNextMinute()
64
    {
65
        $this->assertEqual(1, $this->cal->nextMinute());
66
    }
67
68
    public function testPrevSecond()
69
    {
70
        $this->assertEqual(59, $this->cal->prevSecond());
71
    }
72
73
    public function testThisSecond()
74
    {
75
        $this->assertEqual(0, $this->cal->thisSecond());
76
    }
77
78
    public function testNextSecond()
79
    {
80
        $this->assertEqual(1, $this->cal->nextSecond());
81
    }
82
83
    public function testGetTimeStamp()
84
    {
85
        $stamp = mktime(0, 0, 0, 10, 25, 2003);
86
        $this->assertEqual($stamp, $this->cal->getTimestamp());
87
    }
88
}
89
90
/**
91
 * Class TestOfDayBuild.
92
 */
93
class TestOfDayBuild extends TestOfDay
94
{
95
    /**
96
     * TestOfDayBuild constructor.
97
     */
98
    public function __construct()
99
    {
100
        $this->UnitTestCase('Test of Day::build()');
101
    }
102
103
    public function testSize()
104
    {
105
        $this->cal->build();
106
        $this->assertEqual(24, $this->cal->size());
107
    }
108
109
    public function testFetch()
110
    {
111
        $this->cal->build();
112
        $i = 0;
113
        while ($Child = $this->cal->fetch()) {
0 ignored issues
show
Unused Code introduced by
The assignment to $Child is dead and can be removed.
Loading history...
114
            ++$i;
115
        }
116
        $this->assertEqual(24, $i);
117
    }
118
119
    public function testFetchAll()
120
    {
121
        $this->cal->build();
122
        $children = [];
123
        $i        = 0;
124
        while ($Child = $this->cal->fetch()) {
125
            $children[$i] = $Child;
126
            ++$i;
127
        }
128
        $this->assertEqual($children, $this->cal->fetchAll());
129
    }
130
131
    public function testSelection()
132
    {
133
        require_once CALENDAR_ROOT . 'Hour.php';
134
        $selection = [new Calendar_Hour(2003, 10, 25, 13)];
135
        $this->cal->build($selection);
136
        $i = 0;
137
        while ($Child = $this->cal->fetch()) {
138
            if (13 == $i) {
139
                break;
140
            }
141
            ++$i;
142
        }
143
        $this->assertTrue($Child->isSelected());
144
    }
145
}
146
147
if (!defined('TEST_RUNNING')) {
148
    define('TEST_RUNNING', true);
149
    $test = new TestOfDay();
150
    $test->run(new HtmlReporter());
0 ignored issues
show
Bug introduced by
The type HtmlReporter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
151
    $test = new TestOfDayBuild();
152
    $test->run(new HtmlReporter());
153
}
154