12
12
*/
13
13
class TimerTest extends TestCase {
14
14
15
- public function testUnsupportedKeyType (){
15
+ public function testUnsupportedKeyType (): void {
16
16
$ this ->expectException (\TypeError::class);
17
17
Timer::start (new \stdClass ());
18
18
}
19
19
20
- private function sleepHalfSec (int $ count = 1 ) {
20
+ private function sleepHalfSec (int $ count = 1 ): void {
21
21
usleep (500000 * $ count );
22
22
}
23
23
24
- public function testStopValuesRetained () {
24
+ public function testStopValuesRetained (): void {
25
25
Timer::start (__FUNCTION__ );
26
26
Timer::stop (__FUNCTION__ );
27
27
$ stopped_at = Timer::read (__FUNCTION__ , Timer::FORMAT_PRECISE );
28
28
$ this ->sleepHalfSec ();
29
29
$ this ->assertEquals (Timer::read (__FUNCTION__ , Timer::FORMAT_PRECISE ), $ stopped_at );
30
30
}
31
31
32
- public function testUnstoppedValuesContinue () {
32
+ public function testUnstoppedValuesContinue (): void {
33
33
Timer::start (__FUNCTION__ );
34
34
$ stopped_at = Timer::read (__FUNCTION__ );
35
35
usleep (500 );
36
36
$ this ->assertGreaterThan ($ stopped_at , Timer::read (__FUNCTION__ , Timer::FORMAT_PRECISE ));
37
37
}
38
38
39
- public function testIndividualTimersRunConcurrent () {
39
+ public function testIndividualTimersRunConcurrent (): void {
40
40
Timer::resetAll ();
41
41
42
42
Timer::start (1 );
@@ -53,7 +53,7 @@ public function testIndividualTimersRunConcurrent() {
53
53
$ this ->assertEquals (Timer::read (1 , Timer::FORMAT_PRECISE ), $ timer_1 );
54
54
}
55
55
56
- public function testMultipleStartsQueued () {
56
+ public function testMultipleStartsQueued (): void {
57
57
$ key = __FUNCTION__ ;
58
58
Timer::start ($ key );
59
59
$ this ->sleepHalfSec ();
@@ -75,7 +75,7 @@ public function testMultipleStartsQueued() {
75
75
$ this ->assertGreaterThan ($ timer_1 + $ timer_2 , $ timer_3 );
76
76
}
77
77
78
- public function testMultipleStartCallsQueued_2 () {
78
+ public function testMultipleStartCallsQueued_2 (): void {
79
79
$ key = 'foo ' ;
80
80
Timer::start ($ key );
81
81
$ this ->assertLessThan (500 , Timer::read ($ key ));
@@ -87,7 +87,7 @@ public function testMultipleStartCallsQueued_2() {
87
87
$ this ->assertLessThan (2000 , Timer::read ($ key ));
88
88
}
89
89
90
- public function testStopAndGoTimer () {
90
+ public function testStopAndGoTimer (): void {
91
91
Timer::start (__FUNCTION__ );
92
92
usleep (1000 );
93
93
Timer::stop (__FUNCTION__ );
@@ -100,15 +100,15 @@ public function testStopAndGoTimer() {
100
100
$ this ->assertLessThan (0.008 , $ timer );
101
101
}
102
102
103
- public function testResetRestsTimer () {
103
+ public function testResetRestsTimer (): void {
104
104
Timer::resetAll ();
105
105
Timer::start (__FUNCTION__ );
106
106
Timer::reset (__FUNCTION__ );
107
107
$ this ->expectException (\LogicException::class);
108
108
Timer::read (__FUNCTION__ );
109
109
}
110
110
111
- public function testTimerFormat_Seconds () {
111
+ public function testTimerFormat_Seconds (): void {
112
112
Timer::start (__FUNCTION__ );
113
113
114
114
usleep (1000 );
@@ -120,35 +120,35 @@ public function testTimerFormat_Seconds() {
120
120
$ this ->assertGreaterThanOrEqual ('0.002 ' , $ read );
121
121
}
122
122
123
- public function testTimerFormat_Unspecified () {
123
+ public function testTimerFormat_Unspecified (): void {
124
124
Timer::start (__FUNCTION__ );
125
125
usleep (1500 );
126
126
$ read = Timer::read (__FUNCTION__ , 'unspecified ' );
127
127
128
128
$ this ->assertGreaterThanOrEqual (1 , $ read );
129
129
}
130
130
131
- public function testTimerFormat_Milliseconds () {
131
+ public function testTimerFormat_Milliseconds (): void {
132
132
Timer::start (__FUNCTION__ );
133
133
usleep (1500 );
134
134
$ read = Timer::read (__FUNCTION__ , Timer::FORMAT_MILLISECONDS );
135
135
136
136
$ this ->assertGreaterThanOrEqual (1 , $ read );
137
137
}
138
138
139
- public function testStopWithoutInitializing () {
139
+ public function testStopWithoutInitializing (): void {
140
140
Timer::resetAll ();
141
141
$ this ->expectException (\LogicException::class);
142
142
Timer::stop (__FUNCTION__ );
143
143
}
144
144
145
145
146
- public function testValidSecondsCount () {
146
+ public function testValidSecondsCount (): void {
147
147
Timer::start (__FUNCTION__ );
148
148
$ this ->assertIsString (Timer::read (__FUNCTION__ ));
149
149
}
150
150
151
- public function testDenyAccessWithoutInitializing () {
151
+ public function testDenyAccessWithoutInitializing (): void {
152
152
$ this ->expectException (\LogicException::class);
153
153
Timer::resetAll ();
154
154
Timer::read ();
0 commit comments