We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3654b6f commit 5753a55Copy full SHA for 5753a55
1 file changed
test/phpunit/LoopTest.php
@@ -130,4 +130,30 @@ public function testRunWithTimerNoNextRunTime() {
130
131
self::assertEquals(0, $sut->getTriggerCount());
132
}
133
+
134
+ public function testHalt() {
135
+ $epoch = microtime(true);
136
+ $tickCount = 0;
137
138
+ $sut = new Loop();
139
140
+ $timer = self::createMock(Timer::class);
141
+ $timer->method("isScheduled")
142
+ ->willReturn(true);
143
+ $timer->method("getNextRunTime")
144
+ ->willReturn($epoch);
145
+ $timer->method("tick")
146
+ ->willReturnCallback(function() use($sut, &$tickCount) {
147
+ $tickCount++;
148
149
+ if($tickCount === 10) {
150
+ $sut->halt();
151
+ }
152
+ return true;
153
+ });
154
155
+ $sut->addTimer($timer);
156
+ $sut->run();
157
+ self::assertEquals(10, $tickCount);
158
159
0 commit comments