<?php

/**
 * TEST: Timer callbacks test.
 */

declare(strict_types=1);
use Tester\Assert;
require(__DIR__ . '/../bootstrap.php');

$loop = React\EventLoop\Factory::create();

$timer = new Awaited\Timer($loop, 0.01);

$calls = 0;

$callback = function() use(&$calls): void {
	$calls++;
};

$timer->add($callback);
$timer->add($callback);

$timer->elapse();

Assert::same(1, $calls);

$timer->remove($callback);

$timer->elapse();

Assert::same(1, $calls);