php-kilo/tests/EventTest.php
Timothy Warren 60b1cca695
All checks were successful
timw4mail/php-kilo/master This commit looks good
Cut down on number of keycode escapes with constants
2020-01-29 16:13:05 -05:00

28 lines
636 B
PHP

<?php declare(strict_types=1);
namespace Aviat\Kilo\Tests;
use Aviat\Kilo\Event;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
class EventTest extends TestCase {
public function testRequiresValidEvent(): void
{
$this->expectException(InvalidArgumentException::class);
Event::on('badEventName', fn () => null);
$this->expectException(InvalidArgumentException::class);
Event::fire('badEventName', []);
}
public function testBindAndFire(): void
{
$fn = static function($value = false) {
static::assertTrue($value);
};
Event::on(Event::INPUT_KEY, $fn);
Event::fire(Event::INPUT_KEY, TRUE);
}
}