-
Notifications
You must be signed in to change notification settings - Fork 431
Expand file tree
/
Copy pathStompDestinationTest.php
More file actions
66 lines (53 loc) · 2.39 KB
/
Copy pathStompDestinationTest.php
File metadata and controls
66 lines (53 loc) · 2.39 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
57
58
59
60
61
62
63
64
65
66
<?php
namespace Enqueue\Stomp\Tests;
use Enqueue\Stomp\ExtensionType;
use Enqueue\Stomp\StompDestination;
use Enqueue\Test\ClassExtensionTrait;
use Interop\Queue\Queue;
use Interop\Queue\Topic;
class StompDestinationTest extends \PHPUnit\Framework\TestCase
{
use ClassExtensionTrait;
public function testShouldImplementsTopicAndQueueInterfaces()
{
$this->assertClassImplements(Topic::class, StompDestination::class);
$this->assertClassImplements(Queue::class, StompDestination::class);
}
public function testShouldReturnDestinationStringWithRoutingKey()
{
$destination = new StompDestination(ExtensionType::RABBITMQ);
$destination->setType(StompDestination::TYPE_AMQ_QUEUE);
$destination->setStompName('name');
$destination->setRoutingKey('routing-key');
$this->assertSame(StompDestination::TYPE_AMQ_QUEUE, $destination->getType());
$this->assertSame('name', $destination->getStompName());
$this->assertSame('routing-key', $destination->getRoutingKey());
$this->assertSame('/amq/queue/name/routing-key', $destination->getQueueName());
}
public function testShouldReturnDestinationStringWithoutRoutingKey()
{
$destination = new StompDestination(ExtensionType::RABBITMQ);
$destination->setType(StompDestination::TYPE_TOPIC);
$destination->setStompName('name');
$this->assertSame(StompDestination::TYPE_TOPIC, $destination->getType());
$this->assertSame('name', $destination->getStompName());
$this->assertNull($destination->getRoutingKey());
$this->assertSame('/topic/name', $destination->getQueueName());
}
public function testShouldThrowLogicExceptionIfNameIsNotSet()
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Destination name is not set');
$destination = new StompDestination(ExtensionType::RABBITMQ);
$destination->setType(StompDestination::TYPE_QUEUE);
$destination->setStompName('');
$destination->getQueueName();
}
public function testSetTypeShouldThrowLogicExceptionIfTypeIsInvalid()
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Invalid destination type: "invalid-type"');
$destination = new StompDestination(ExtensionType::RABBITMQ);
$destination->setType('invalid-type');
}
}