mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-07 15:54:26 +02:00
EventDispatcher proof of concept
This commit is contained in:
parent
827541ed86
commit
9e6f77c4b1
17 changed files with 887 additions and 27 deletions
37
tests/Unit/Event/EventDispatcherTest.php
Normal file
37
tests/Unit/Event/EventDispatcherTest.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Event;
|
||||
|
||||
use Friendica\Event\Event;
|
||||
use Friendica\Event\EventDispatcher;
|
||||
use Friendica\Event\NamedEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class EventDispatcherTest extends TestCase
|
||||
{
|
||||
public function testImplementationOfInstances(): void
|
||||
{
|
||||
$eventDispatcher = new EventDispatcher();
|
||||
|
||||
$this->assertInstanceOf(EventDispatcherInterface::class, $eventDispatcher);
|
||||
}
|
||||
|
||||
public function testDispatchANamedEventUsesNameAsEventName(): void
|
||||
{
|
||||
$eventDispatcher = new EventDispatcher();
|
||||
|
||||
$eventDispatcher->addListener('test', function (NamedEvent $event) {
|
||||
$this->assertSame('test', $event->getName());
|
||||
});
|
||||
|
||||
$eventDispatcher->dispatch(new Event('test'));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue