mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-02 14:25:38 +08:00
fix EventMapIterator bug and add tests
This commit is contained in:
33
tests/ZM/Event/EventMapIteratorTest.php
Normal file
33
tests/ZM/Event/EventMapIteratorTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\ZM\Event;
|
||||
|
||||
use Module\Example\Hello;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ZM\Annotation\CQ\CommandArgument;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Event\EventMapIterator;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class EventMapIteratorTest extends TestCase
|
||||
{
|
||||
public function testIterator(): void
|
||||
{
|
||||
Console::setLevel(4);
|
||||
$iterator = new EventMapIterator(Hello::class, 'randNum', CommandArgument::class);
|
||||
$arr = iterator_to_array($iterator);
|
||||
$this->assertArrayNotHasKey(0, $arr);
|
||||
$this->assertArrayNotHasKey(1, $arr);
|
||||
$this->assertArrayHasKey(2, $arr);
|
||||
$this->assertArrayHasKey(3, $arr);
|
||||
$this->assertInstanceOf(CommandArgument::class, $arr[2]);
|
||||
$this->assertInstanceOf(CommandArgument::class, $arr[3]);
|
||||
$iterator = new EventMapIterator(Hello::class, 'closeUnknownConn', CommandArgument::class);
|
||||
$ls = iterator_to_array($iterator);
|
||||
$this->assertCount(0, $ls);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user