1 | <?php declare(strict_types = 1); |
||
2 | |||
3 | namespace Portiny\RabbitMQ\Tests; |
||
4 | |||
5 | use Bunny\Async\Client as AsyncClient; |
||
6 | use Bunny\Client; |
||
7 | use PHPUnit\Framework\TestCase; |
||
8 | use Portiny\RabbitMQ\BunnyManager; |
||
9 | use Portiny\RabbitMQ\Tests\Source\TestConsumer; |
||
10 | use React\EventLoop\Factory; |
||
11 | |||
12 | final class BunnyManagerTest extends TestCase |
||
13 | { |
||
14 | /** |
||
15 | * @var BunnyManager |
||
16 | */ |
||
17 | private $bunnyManager; |
||
18 | |||
19 | |||
20 | protected function setUp(): void |
||
21 | { |
||
22 | parent::setUp(); |
||
23 | |||
24 | $this->bunnyManager = $this->createBunnyManager(); |
||
25 | } |
||
26 | |||
27 | |||
28 | public function testGetClient(): void |
||
29 | { |
||
30 | $client = $this->bunnyManager->getClient(); |
||
31 | |||
32 | self::assertInstanceOf(Client::class, $client); |
||
33 | self::assertSame($client, $this->bunnyManager->getClient()); |
||
34 | } |
||
35 | |||
36 | |||
37 | public function testGetAsyncClient(): void |
||
38 | { |
||
39 | $loop = Factory::create(); |
||
0 ignored issues
–
show
|
|||
40 | $this->bunnyManager->setLoop($loop); |
||
41 | |||
42 | $client = $this->bunnyManager->getClient(); |
||
43 | |||
44 | self::assertInstanceOf(AsyncClient::class, $client); |
||
45 | self::assertSame($client, $this->bunnyManager->getClient()); |
||
46 | } |
||
47 | |||
48 | |||
49 | public function testGetClassNameByAlias(): void |
||
50 | { |
||
51 | self::assertInstanceOf(TestConsumer::class, $this->bunnyManager->getConsumerByAlias('myAlias')); |
||
52 | self::assertNull($this->bunnyManager->getConsumerByAlias('nonExisting')); |
||
53 | } |
||
54 | |||
55 | |||
56 | protected function createBunnyManager(): BunnyManager |
||
57 | { |
||
58 | return new BunnyManager( |
||
59 | [ |
||
60 | 'host' => '127.0.0.10', |
||
61 | 'port' => 9999, |
||
62 | 'user' => 'guest', |
||
63 | 'password' => 'guest', |
||
64 | 'vhost' => '/', |
||
65 | 'timeout' => 1, |
||
66 | 'heartbeat' => 60.0, |
||
67 | 'persistent' => false, |
||
68 | 'path' => '/', |
||
69 | 'tcp_nodelay' => false, |
||
70 | ], |
||
71 | [ |
||
72 | 'myAlias' => 'Portiny\\RabbitMQ\\Tests\\Source\\TestConsumer', |
||
73 | ], |
||
74 | [new TestConsumer()], |
||
75 | [], |
||
76 | [] |
||
77 | ); |
||
78 | } |
||
79 | |||
80 | } |
||
81 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.