Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getSentEmail example
$message
=
new
ChatMessage
(
$subject
= 'Hello!',
new
TestOptions
(
[
'recipient_id' =>
$recipient
= 'Oskar'
]
)
)
;
$mailer
=
new
DummyMailer
(
)
;
$transport
=
(
new
FakeChatEmailTransport
(
$mailer
,
$to
= 'recipient@email.net',
$from
= 'sender@email.net'
)
)
;
$transport
->
setHost
(
$transportName
)
;
$transport
->
send
(
$message
)
;
/** @var Email $sentEmail */
$sentEmail
=
$mailer
->
getSentEmail
(
)
;
$this
->
assertInstanceOf
(
Email::
class
,
$sentEmail
)
;
$this
->
assertSame
(
$to
,
$sentEmail
->
getTo
(
)
[
0
]
->
getEncodedAddress
(
)
)
;
$this
->
assertSame
(
$from
,
$sentEmail
->
getFrom
(
)
[
0
]
->
getEncodedAddress
(
)
)
;
$this
->
assertSame
(
sprintf
(
'New Chat message for recipient: %s',
$recipient
)
,
$sentEmail
->
getSubject
(
)
)
;
$this
->
assertSame
(
$subject
,
$sentEmail
->
getTextBody
(
)
)
;
$this
->
assertFalse
(
$sentEmail
->
getHeaders
(
)
->
has
(
'X-Transport'
)
)
;
}
public
function
testSendWithDefaultTransportAndWithoutRecipient
(
)
{
$transportName
= null;
$message
=
new
SmsMessage
(
$phone
= '0611223344',
$subject
= 'Hello!'
)
;
$mailer
=
new
DummyMailer
(
)
;
$transport
=
(
new
FakeSmsEmailTransport
(
$mailer
,
$to
= 'recipient@email.net',
$from
= 'sender@email.net'
)
)
;
$transport
->
setHost
(
$transportName
)
;
$transport
->
send
(
$message
)
;
/** @var Email $sentEmail */
$sentEmail
=
$mailer
->
getSentEmail
(
)
;
$this
->
assertInstanceOf
(
Email::
class
,
$sentEmail
)
;
$this
->
assertSame
(
$to
,
$sentEmail
->
getTo
(
)
[
0
]
->
getEncodedAddress
(
)
)
;
$this
->
assertSame
(
$from
,
$sentEmail
->
getFrom
(
)
[
0
]
->
getEncodedAddress
(
)
)
;
$this
->
assertSame
(
sprintf
(
'New SMS on phone number: %s',
$phone
)
,
$sentEmail
->
getSubject
(
)
)
;
$this
->
assertSame
(
$subject
,
$sentEmail
->
getTextBody
(
)
)
;
$this
->
assertFalse
(
$sentEmail
->
getHeaders
(
)
->
has
(
'X-Transport'
)
)
;
}
public
function
testSendWithCustomTransport
(
)
{
$transportName
= 'mailchimp';