Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
MercureRuntimeException example
public
function
testSendWithNonMercureOptionsThrows
(
)
{
$this
->
expectException
(
LogicException::
class
)
;
self::
createTransport
(
)
->
send
(
new
ChatMessage
(
'testMessage',
$this
->
createMock
(
MessageOptionsInterface::
class
)
)
)
;
}
public
function
testSendWithTransportFailureThrows
(
)
{
$hub
=
new
MockHub
(
'https://foo.com/.well-known/mercure',
new
StaticTokenProvider
(
'foo'
)
,
static
function
D
)
: void
{
throw
new
MercureRuntimeException
(
'Cannot connect to mercure'
)
;
}
)
;
$this
->
expectException
(
RuntimeException::
class
)
;
$this
->
expectExceptionMessage
(
'Unable to post the Mercure message: Cannot connect to mercure'
)
;
self::
createTransport
(
null,
$hub
)
->
send
(
new
ChatMessage
(
'subject'
)
)
;
}
public
function
testSendWithWrongTokenThrows
(
)
{
$hub
=
new
MockHub
(
'https://foo.com/.well-known/mercure',
new
StaticTokenProvider
(
'foo'
)
,
static
function
D
)
: void
{