update to 2.5.0-b2 (build 409)

This commit is contained in:
crazywhalecc
2021-07-04 15:45:30 +08:00
parent 4ee16d4fc6
commit 7ec847e576
28 changed files with 467 additions and 87 deletions

View File

@@ -11,6 +11,7 @@ use ReflectionException;
use ZM\Annotation\AnnotationParser;
use ZM\Annotation\Swoole\OnStart;
use ZM\Console\Console;
use ZM\Event\EventTracer;
class AnnotationParserRegisterTest extends TestCase
{
@@ -21,7 +22,7 @@ class AnnotationParserRegisterTest extends TestCase
define("WORKING_DIR", realpath(__DIR__ . "/../../../"));
if (!defined("LOAD_MODE"))
define("LOAD_MODE", 0);
Console::init(2);
Console::init(4);
$this->parser = new AnnotationParser();
$this->parser->addRegisterPath(WORKING_DIR . "/src/Module/", "Module");
try {
@@ -70,4 +71,8 @@ class AnnotationParserRegisterTest extends TestCase
$mapping = $this->parser->getReqMapping();
$this->assertEquals("index", $mapping["method"]);
}
public function testTracer() {
}
}

View File

@@ -8,11 +8,14 @@ use Doctrine\Common\Annotations\AnnotationException;
use Module\Example\Hello;
use PHPUnit\Framework\TestCase;
use ReflectionException;
use Swoole\Atomic;
use ZM\Annotation\AnnotationParser;
use ZM\Annotation\CQ\CQCommand;
use ZM\Console\Console;
use ZM\Event\EventDispatcher;
use ZM\Event\EventManager;
use ZM\Store\LightCacheInside;
use ZM\Store\ZMAtomic;
class EventDispatcherTest extends TestCase
{
@@ -23,7 +26,9 @@ class EventDispatcherTest extends TestCase
define("WORKING_DIR", realpath(__DIR__ . "/../../../"));
if (!defined("LOAD_MODE"))
define("LOAD_MODE", 0);
Console::init(2);
Console::init(4);
ZMAtomic::$atomics["_event_id"] = new Atomic(0);
LightCacheInside::init();
$parser = new AnnotationParser();
$parser->addRegisterPath(WORKING_DIR . "/src/Module/", "Module");
try {
@@ -44,5 +49,13 @@ class EventDispatcherTest extends TestCase
$r = ob_get_clean();
echo $r;
$this->assertStringContainsString("你好啊", $r);
$dispatcher = new EventDispatcher(CQCommand::class);
$dispatcher->setReturnFunction(function ($result) {
//echo $result . PHP_EOL;
});
//$dispatcher->setRuleFunction(function ($v) { return $v->match == "qwe"; });
$dispatcher->setRuleFunction(function ($v) { return $v->match == "qwe"; });
//$dispatcher->setRuleFunction(fn ($v) => $v->match == "qwe");
$dispatcher->dispatchEvents();
}
}