php-kilo/tests/EventTest.php

29 lines
688 B
PHP
Raw Normal View History

2020-01-27 15:11:35 -05:00
<?php declare(strict_types=1);
namespace Aviat\Kilo\Tests;
use Aviat\Kilo\Event;
use Aviat\Kilo\Enum\Event as EventType;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
class EventTest extends TestCase {
public function testRequiresValidEvent(): void
{
$this->expectException(InvalidArgumentException::class);
Event::bind('badEventName', fn () => null);
$this->expectException(InvalidArgumentException::class);
Event::fire('badEventName', []);
}
public function testBindAndFire(): void
{
$fn = static function($value = false) {
static::assertTrue($value);
};
Event::bind(EventType::INPUT_KEY, $fn);
Event::fire(EventType::INPUT_KEY, TRUE);
}
}