Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
StrictValidAt example
public
function
testInvalidateToken
(
)
: void
{
$success
=
$this
->tokenFactory->
invalidateToken
(
Uuid::
randomHex
(
)
)
;
static
::
assertFalse
(
$success
)
;
}
public
function
testExpiredToken
(
)
: void
{
$configuration
= Configuration::
forSymmetricSigner
(
new
TestSigner
(
)
,
new
TestKey
(
)
)
;
$configuration
->
setValidationConstraints
(
new
StrictValidAt
(
new
FrozenClock
(
new
\
DateTimeImmutable
(
'now - 1 day'
)
)
)
)
;
$tokenFactory
=
new
JWTFactoryV2
(
$configuration
,
$this
->
createMock
(
Connection::
class
)
)
;
$transaction
= self::
createTransaction
(
)
;
$tokenStruct
=
new
TokenStruct
(
null, null,
$transaction
->
getPaymentMethodId
(
)
,
$transaction
->
getId
(
)
, null, -50
)
;
$token
=
$tokenFactory
->
generateToken
(
$tokenStruct
)
;
if
(
!Feature::
isActive
(
'v6.6.0.0'
)
)
{
$this
->
expectException
(
InvalidTokenException::
class
)
;
}
$this
->
expectException
(
PaymentException::
class
)
;