-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBootProcessListenerTest.php
More file actions
56 lines (51 loc) · 1.49 KB
/
BootProcessListenerTest.php
File metadata and controls
56 lines (51 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace HyperfTest\Process;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\Process\Annotation\Process;
use Hyperf\Process\Listener\BootProcessListener;
use HyperfTest\Process\Stub\FooProcess;
use Mockery;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use ReflectionClass;
/**
* @internal
* @coversNothing
*/
#[CoversNothing]
/**
* @internal
* @coversNothing
*/
class BootProcessListenerTest extends TestCase
{
protected function tearDown(): void
{
Mockery::close();
AnnotationCollector::clear();
}
public function testGetAnnotationProcesses()
{
$annotation = new Process(name: 'foo');
$annotation->collectClass(FooProcess::class);
$listener = new BootProcessListener(Mockery::mock(ContainerInterface::class), Mockery::mock(ConfigInterface::class));
$ref = new ReflectionClass($listener);
$method = $ref->getMethod('getAnnotationProcesses');
$res = $method->invoke($listener);
foreach ($res as $class => $annotation) {
$this->assertSame(FooProcess::class, $class);
$this->assertInstanceOf(Process::class, $annotation);
}
}
}