mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 12:47:55 +08:00
Format
This commit is contained in:
parent
b1c470447c
commit
2a80076951
@ -1,11 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Hyperf\Event;
|
||||
|
||||
|
||||
trait Stoppable
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@ -17,8 +25,8 @@ trait Stoppable
|
||||
* previous listener halted propagation.
|
||||
*
|
||||
* @return bool
|
||||
* True if the Event is complete and no further listeners should be called.
|
||||
* False to continue calling listeners.
|
||||
* True if the Event is complete and no further listeners should be called.
|
||||
* False to continue calling listeners.
|
||||
*/
|
||||
public function isPropagationStopped(): bool
|
||||
{
|
||||
@ -30,5 +38,4 @@ trait Stoppable
|
||||
$this->propagation = $propagation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace HyperfTest\Event;
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace HyperfTest\Event;
|
||||
|
||||
use Hyperf\Event\ConfigProvider;
|
||||
use Hyperf\Event\EventDispatcher;
|
||||
@ -10,6 +19,10 @@ use PHPUnit\Framework\TestCase;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\EventDispatcher\ListenerProviderInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ConfigProviderTest extends TestCase
|
||||
{
|
||||
public function testInvoke()
|
||||
@ -26,6 +39,4 @@ class ConfigProviderTest extends TestCase
|
||||
],
|
||||
], (new ConfigProvider())());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace HyperfTest\Event\Event;
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace HyperfTest\Event\Event;
|
||||
|
||||
use Hyperf\Event\Stoppable;
|
||||
use Psr\EventDispatcher\StoppableEventInterface;
|
||||
|
||||
class Alpha implements StoppableEventInterface
|
||||
{
|
||||
|
||||
use Stoppable;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace HyperfTest\Event\Event;
|
||||
|
||||
|
||||
class Beta
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace HyperfTest\Event;
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace HyperfTest\Event;
|
||||
|
||||
use Hyperf\Event\EventDispatcher;
|
||||
use Hyperf\Event\ListenerProvider;
|
||||
use HyperfTest\Event\Event\Alpha;
|
||||
use HyperfTest\Event\Event\Beta;
|
||||
use HyperfTest\Event\Listener\AlphaListener;
|
||||
use HyperfTest\Event\Listener\BetaListener;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\EventDispatcher\ListenerProviderInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class EventDispatcherTest extends TestCase
|
||||
{
|
||||
public function testInvokeDispatcher()
|
||||
@ -33,6 +44,4 @@ class EventDispatcherTest extends TestCase
|
||||
$this->assertSame(2, $alphaListener->value);
|
||||
$this->assertSame(1, $betaListener->value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace HyperfTest\Event\Listener;
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace HyperfTest\Event\Listener;
|
||||
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use HyperfTest\Event\Event\Alpha;
|
||||
|
||||
class AlphaListener implements ListenerInterface
|
||||
{
|
||||
|
||||
public $value = 1;
|
||||
|
||||
/**
|
||||
@ -29,5 +37,4 @@ class AlphaListener implements ListenerInterface
|
||||
{
|
||||
$this->value = 2;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace HyperfTest\Event\Listener;
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace HyperfTest\Event\Listener;
|
||||
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use HyperfTest\Event\Event\Beta;
|
||||
|
||||
class BetaListener implements ListenerInterface
|
||||
{
|
||||
|
||||
public $value = 1;
|
||||
|
||||
/**
|
||||
@ -29,5 +37,4 @@ class BetaListener implements ListenerInterface
|
||||
{
|
||||
$this->value = 2;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace HyperfTest\Event;
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://hyperf.org
|
||||
* @document https://wiki.hyperf.org
|
||||
* @contact group@hyperf.org
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace HyperfTest\Event;
|
||||
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
@ -20,9 +29,12 @@ use Psr\Container\ContainerInterface;
|
||||
use Psr\EventDispatcher\ListenerProviderInterface;
|
||||
use SplPriorityQueue;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ListenerTest extends TestCase
|
||||
{
|
||||
|
||||
use MockeryPHPUnitIntegration;
|
||||
|
||||
public function testInvokeListenerProvider()
|
||||
@ -74,7 +86,7 @@ class ListenerTest extends TestCase
|
||||
'listeners' => [
|
||||
AlphaListener::class,
|
||||
BetaListener::class,
|
||||
]
|
||||
],
|
||||
]));
|
||||
$container->shouldReceive('get')
|
||||
->with(AlphaListener::class)
|
||||
@ -141,19 +153,18 @@ class ListenerTest extends TestCase
|
||||
$this->assertSame(1, $listenerAnnotation->priority);
|
||||
// Define the priority.
|
||||
$listenerAnnotation = new ListenerAnnotation([
|
||||
'priority' => 2
|
||||
'priority' => 2,
|
||||
]);
|
||||
$this->assertSame(2, $listenerAnnotation->priority);
|
||||
// String number
|
||||
$listenerAnnotation = new ListenerAnnotation([
|
||||
'priority' => "2"
|
||||
'priority' => '2',
|
||||
]);
|
||||
$this->assertSame(2, $listenerAnnotation->priority);
|
||||
// Non-number
|
||||
$listenerAnnotation = new ListenerAnnotation([
|
||||
'priority' => "string"
|
||||
'priority' => 'string',
|
||||
]);
|
||||
$this->assertSame(1, $listenerAnnotation->priority);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user