mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-17 20:54:52 +08:00
add Terminal related test
This commit is contained in:
parent
4defd8ac1b
commit
b6742526aa
@ -9,6 +9,7 @@ use Closure;
|
||||
use Doctrine\Common\Annotations\AnnotationException;
|
||||
use Error;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Exception\InterruptException;
|
||||
@ -110,7 +111,7 @@ class EventDispatcher
|
||||
|
||||
/**
|
||||
* @param mixed ...$params
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function dispatchEvents(...$params)
|
||||
{
|
||||
@ -137,7 +138,7 @@ class EventDispatcher
|
||||
} catch (InterruptException $e) {
|
||||
$this->store = $e->return_var;
|
||||
$this->status = self::STATUS_INTERRUPTED;
|
||||
} catch (Exception|Error $e) {
|
||||
} catch (Throwable $e) {
|
||||
$this->status = self::STATUS_EXCEPTION;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@ -7,10 +7,10 @@ declare(strict_types=1);
|
||||
namespace ZM\Utils;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Error;
|
||||
use Exception;
|
||||
use ReflectionClass;
|
||||
use Swoole\Process;
|
||||
use Throwable;
|
||||
use ZM\Annotation\Command\TerminalCommand;
|
||||
use ZM\ConnectionManager\ManagerGM;
|
||||
use ZM\Console\Console;
|
||||
@ -22,8 +22,7 @@ class Terminal
|
||||
public static $default_commands = false;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws Error
|
||||
* @throws Throwable
|
||||
* @return bool
|
||||
* @noinspection PhpMissingReturnTypeInspection
|
||||
* @noinspection PhpUnused
|
||||
|
||||
33
tests/ZM/Utils/TerminalTest.php
Normal file
33
tests/ZM/Utils/TerminalTest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\ZM\Utils;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Throwable;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Utils\Terminal;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class TerminalTest extends TestCase
|
||||
{
|
||||
public function testInit()
|
||||
{
|
||||
Console::setLevel(4);
|
||||
Terminal::init();
|
||||
$this->assertStringContainsString('Initializing Terminal', $this->getActualOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function testExecuteCommand()
|
||||
{
|
||||
Console::setLevel(2);
|
||||
Terminal::executeCommand('echo zhamao-framework');
|
||||
$this->assertStringContainsString('zhamao-framework', $this->getActualOutput());
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user