Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
purgeQueues example
if
(
!
getenv
(
'MESSENGER_AMQP_DSN'
)
)
{
$this
->
markTestSkipped
(
'The "MESSENGER_AMQP_DSN" environment variable is required.'
)
;
}
}
public
function
testItSendsAndReceivesMessages
(
)
{
$serializer
=
$this
->
createSerializer
(
)
;
$connection
= Connection::
fromDsn
(
getenv
(
'MESSENGER_AMQP_DSN'
)
)
;
$connection
->
setup
(
)
;
$connection
->
purgeQueues
(
)
;
$sender
=
new
AmqpSender
(
$connection
,
$serializer
)
;
$receiver
=
new
AmqpReceiver
(
$connection
,
$serializer
)
;
$sender
->
send
(
$first
=
new
Envelope
(
new
DummyMessage
(
'First'
)
)
)
;
$sender
->
send
(
$second
=
new
Envelope
(
new
DummyMessage
(
'Second'
)
)
)
;
$envelopes
=
iterator_to_array
(
$receiver
->
get
(
)
)
;
$this
->
assertCount
(
1,
$envelopes
)
;
/** @var Envelope $envelope */
$envelope
=
$envelopes
[
0
]
;