255 lines
11 KiB
YAML
255 lines
11 KiB
YAML
name: ConnectionTest
|
|
class_comment: '# * @requires extension amqp
|
|
|
|
# *
|
|
|
|
# * @group time-sensitive'
|
|
dependencies:
|
|
- name: TestCase
|
|
type: class
|
|
source: PHPUnit\Framework\TestCase
|
|
- name: DummyMessage
|
|
type: class
|
|
source: Symfony\Component\Messenger\Bridge\Amqp\Tests\Fixtures\DummyMessage
|
|
- name: AmqpFactory
|
|
type: class
|
|
source: Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpFactory
|
|
- name: AmqpStamp
|
|
type: class
|
|
source: Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpStamp
|
|
- name: Connection
|
|
type: class
|
|
source: Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection
|
|
- name: InvalidArgumentException
|
|
type: class
|
|
source: Symfony\Component\Messenger\Exception\InvalidArgumentException
|
|
properties: []
|
|
methods:
|
|
- name: testFromDsnWithInvalidValueOnQueueArguments
|
|
visibility: public
|
|
parameters:
|
|
- name: dsn
|
|
- name: options
|
|
comment: "# * @requires extension amqp\n# *\n# * @group time-sensitive\n# */\n#\
|
|
\ class ConnectionTest extends TestCase\n# {\n# private const DEFAULT_EXCHANGE_NAME\
|
|
\ = 'messages';\n# \n# public function testItCannotBeConstructedWithAWrongDsn()\n\
|
|
# {\n# $this->expectException(\\InvalidArgumentException::class);\n# $this->expectExceptionMessage('The\
|
|
\ given AMQP DSN is invalid.');\n# Connection::fromDsn('amqp://:');\n# }\n# \n\
|
|
# public function testItCanBeConstructedWithDefaults()\n# {\n# $this->assertEquals(\n\
|
|
# new Connection([\n# 'host' => 'localhost',\n# 'port' => 5672,\n# 'vhost' =>\
|
|
\ '/',\n# ], [\n# 'name' => self::DEFAULT_EXCHANGE_NAME,\n# ], [\n# self::DEFAULT_EXCHANGE_NAME\
|
|
\ => [],\n# ]),\n# Connection::fromDsn('amqp://')\n# );\n# }\n# \n# public function\
|
|
\ testItCanBeConstructedWithAnAmqpsDsn()\n# {\n# $this->assertEquals(\n# new Connection([\n\
|
|
# 'host' => 'localhost',\n# 'port' => 5671,\n# 'vhost' => '/',\n# 'cacert' =>\
|
|
\ '/etc/ssl/certs',\n# ], [\n# 'name' => self::DEFAULT_EXCHANGE_NAME,\n# ], [\n\
|
|
# self::DEFAULT_EXCHANGE_NAME => [],\n# ]),\n# Connection::fromDsn('amqps://localhost?'.\n\
|
|
# 'cacert=/etc/ssl/certs')\n# );\n# }\n# \n# public function testItGetsParametersFromTheDsn()\n\
|
|
# {\n# $this->assertEquals(\n# new Connection([\n# 'host' => 'host',\n# 'port'\
|
|
\ => 5672,\n# 'vhost' => '/',\n# ], [\n# 'name' => 'custom',\n# ], [\n# 'custom'\
|
|
\ => [],\n# ]),\n# Connection::fromDsn('amqp://host/%2f/custom')\n# );\n# }\n\
|
|
# \n# public function testOverrideOptionsViaQueryParameters()\n# {\n# $this->assertEquals(\n\
|
|
# new Connection([\n# 'host' => 'localhost',\n# 'port' => 1234,\n# 'vhost' =>\
|
|
\ 'vhost',\n# 'login' => 'guest',\n# 'password' => 'password',\n# ], [\n# 'name'\
|
|
\ => 'exchangeName',\n# ], [\n# 'queueName' => [],\n# ]),\n# Connection::fromDsn('amqp://guest:password@localhost:1234/vhost/queue?exchange[name]=exchangeName&queues[queueName]')\n\
|
|
# );\n# }\n# \n# public function testOptionsAreTakenIntoAccountAndOverwrittenByDsn()\n\
|
|
# {\n# $this->assertEquals(\n# new Connection([\n# 'host' => 'localhost',\n# 'port'\
|
|
\ => 5672,\n# 'vhost' => '/',\n# 'persistent' => 'true',\n# ], [\n# 'name' =>\
|
|
\ 'exchangeName',\n# ], [\n# 'queueName' => [],\n# ]),\n# Connection::fromDsn('amqp://localhost/%2f/queue?exchange[name]=exchangeName&queues[queueName]',\
|
|
\ [\n# 'persistent' => 'true',\n# 'exchange' => ['name' => 'toBeOverwritten'],\n\
|
|
# ])\n# );\n# }\n# \n# public function testExceptionIfInvalidOptionIsPassedWithDsn()\n\
|
|
# {\n# $this->expectExceptionMessage('Invalid option(s) \"foo\" passed to the\
|
|
\ AMQP Messenger transport.');\n# Connection::fromDsn('amqp://host?foo=bar');\n\
|
|
# }\n# \n# public function testExceptionIfInvalidOptionIsPassedAsArgument()\n\
|
|
# {\n# $this->expectExceptionMessage('Invalid option(s) \"foo\" passed to the\
|
|
\ AMQP Messenger transport.');\n# Connection::fromDsn('amqp://host', ['foo' =>\
|
|
\ 'bar']);\n# }\n# \n# public function testExceptionIfInvalidQueueOptionIsPassed()\n\
|
|
# {\n# $this->expectExceptionMessage('Invalid queue option(s) \"foo\" passed to\
|
|
\ the AMQP Messenger transport.');\n# Connection::fromDsn('amqp://host', ['queues'\
|
|
\ => ['queueName' => ['foo' => 'bar']]]);\n# }\n# \n# public function testExceptionIfInvalidExchangeOptionIsPassed()\n\
|
|
# {\n# $this->expectExceptionMessage('Invalid exchange option(s) \"foo\" passed\
|
|
\ to the AMQP Messenger transport.');\n# Connection::fromDsn('amqp://host', ['exchange'\
|
|
\ => ['foo' => 'bar']]);\n# }\n# \n# public function testSetsParametersOnTheQueueAndExchange()\n\
|
|
# {\n# $factory = new TestAmqpFactory(\n# $amqpConnection = $this->createMock(\\\
|
|
AMQPConnection::class),\n# $amqpChannel = $this->createMock(\\AMQPChannel::class),\n\
|
|
# $amqpQueue = $this->createMock(\\AMQPQueue::class),\n# $amqpExchange = $this->createMock(\\\
|
|
AMQPExchange::class)\n# );\n# \n# $amqpQueue->expects($this->once())->method('setArguments')->with([\n\
|
|
# 'x-dead-letter-exchange' => 'dead-exchange',\n# 'x-delay' => 100,\n# 'x-expires'\
|
|
\ => 150,\n# 'x-max-length' => 200,\n# 'x-max-length-bytes' => 300,\n# 'x-max-priority'\
|
|
\ => 4,\n# 'x-message-ttl' => 100,\n# ]);\n# \n# $amqpExchange->expects($this->once())->method('setArguments')->with([\n\
|
|
# 'alternate-exchange' => 'alternate',\n# ]);\n# \n# $dsn = 'amqp://localhost/%2f/messages?'.\n\
|
|
# 'queues[messages][arguments][x-dead-letter-exchange]=dead-exchange&'.\n# 'queues[messages][arguments][x-message-ttl]=100&'.\n\
|
|
# 'queues[messages][arguments][x-delay]=100&'.\n# 'queues[messages][arguments][x-expires]=150&'\n\
|
|
# ;\n# $connection = Connection::fromDsn($dsn, [\n# 'queues' => [\n# 'messages'\
|
|
\ => [\n# 'arguments' => [\n# 'x-max-length' => '200',\n# 'x-max-length-bytes'\
|
|
\ => '300',\n# 'x-max-priority' => '4',\n# ],\n# ],\n# ],\n# 'delay' => [\n# 'arguments'\
|
|
\ => [\n# 'x-queue-type' => 'classic',\n# 'x-message-deduplication' => true,\n\
|
|
# ],\n# ],\n# 'exchange' => [\n# 'arguments' => [\n# 'alternate-exchange' => 'alternate',\n\
|
|
# ],\n# ],\n# ], $factory);\n# $connection->publish('body');\n# }\n# \n# public\
|
|
\ static function invalidQueueArgumentsDataProvider(): iterable\n# {\n# $baseDsn\
|
|
\ = 'amqp://localhost/%2f/messages';\n# \n# return [\n# [$baseDsn.'?queues[messages][arguments][x-delay]=not-a-number',\
|
|
\ []],\n# [$baseDsn.'?queues[messages][arguments][x-expires]=not-a-number', []],\n\
|
|
# [$baseDsn.'?queues[messages][arguments][x-max-length]=not-a-number', []],\n\
|
|
# [$baseDsn.'?queues[messages][arguments][x-max-length-bytes]=not-a-number', []],\n\
|
|
# [$baseDsn.'?queues[messages][arguments][x-max-priority]=not-a-number', []],\n\
|
|
# [$baseDsn.'?queues[messages][arguments][x-message-ttl]=not-a-number', []],\n\
|
|
# \n# // Ensure the exception is thrown when the arguments are passed via the\
|
|
\ array options\n# [$baseDsn, ['queues' => ['messages' => ['arguments' => ['x-delay'\
|
|
\ => 'not-a-number']]]]],\n# [$baseDsn, ['queues' => ['messages' => ['arguments'\
|
|
\ => ['x-expires' => 'not-a-number']]]]],\n# [$baseDsn, ['queues' => ['messages'\
|
|
\ => ['arguments' => ['x-max-length' => 'not-a-number']]]]],\n# [$baseDsn, ['queues'\
|
|
\ => ['messages' => ['arguments' => ['x-max-length-bytes' => 'not-a-number']]]]],\n\
|
|
# [$baseDsn, ['queues' => ['messages' => ['arguments' => ['x-max-priority' =>\
|
|
\ 'not-a-number']]]]],\n# [$baseDsn, ['queues' => ['messages' => ['arguments'\
|
|
\ => ['x-message-ttl' => 'not-a-number']]]]],\n# ];\n# }\n# \n# /**\n# * @dataProvider\
|
|
\ invalidQueueArgumentsDataProvider"
|
|
- name: testItUsesANormalConnectionByDefault
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItAllowsToUseAPersistentConnection
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItSetupsTheConnectionWithDefaults
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItSetupsTheConnection
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItSetupsTheTTLConnection
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testBindingArguments
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanDisableTheSetup
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItSetupQueuesOnce
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testAutoSetupWithDelayDeclaresExchangeQueuesAndDelay
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItDelaysTheMessage
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItRetriesTheMessage
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItDelaysTheMessageWithADifferentRoutingKeyAndTTLs
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testNoCredentialLeakageWhenConnectionFails
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testNoCaCertOnSslConnectionFromDsn
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testAmqpStampHeadersAreUsed
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testAmqpStampDeliveryModeIsUsed
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanPublishWithTheDefaultRoutingKey
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanPublishWithASuppliedRoutingKey
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanPublishWithCustomFlagsAndAttributes
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItPublishMessagesWithoutWaitingForConfirmation
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testSetChannelToConfirmMessage
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanPublishAndWaitForConfirmation
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanBeConstructedWithTLSOptionsAndNonTLSDsn
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanRetryPublishWhenAMQPConnectionExceptionIsThrown
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItCanRetryPublishWithDelayWhenAMQPConnectionExceptionIsThrown
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testItWillRetryMaxThreeTimesWhenAMQPConnectionExceptionIsThrown
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: createDelayOrRetryConnection
|
|
visibility: private
|
|
parameters:
|
|
- name: delayExchange
|
|
- name: deadLetterExchangeName
|
|
- name: delayQueueName
|
|
comment: null
|
|
- name: __construct
|
|
visibility: public
|
|
parameters:
|
|
- name: connection
|
|
- name: channel
|
|
- name: queue
|
|
- name: exchange
|
|
comment: null
|
|
- name: createConnection
|
|
visibility: public
|
|
parameters:
|
|
- name: credentials
|
|
comment: null
|
|
- name: createChannel
|
|
visibility: public
|
|
parameters:
|
|
- name: connection
|
|
comment: null
|
|
- name: createQueue
|
|
visibility: public
|
|
parameters:
|
|
- name: channel
|
|
comment: null
|
|
- name: createExchange
|
|
visibility: public
|
|
parameters:
|
|
- name: channel
|
|
comment: null
|
|
traits:
|
|
- PHPUnit\Framework\TestCase
|
|
- Symfony\Component\Messenger\Bridge\Amqp\Tests\Fixtures\DummyMessage
|
|
- Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpFactory
|
|
- Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpStamp
|
|
- Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection
|
|
- Symfony\Component\Messenger\Exception\InvalidArgumentException
|
|
interfaces: []
|