Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
UserRecoveryEntity example
/** * @internal * * @covers \Shopware\Core\System\User\Recovery\UserRecoveryRequestEvent */
#[Package('system-settings')]
class
UserRecoveryRequestEventTest
extends
TestCase
{
public
function
testScalarValuesCorrectly
(
)
: void
{
$event
=
new
UserRecoveryRequestEvent
(
new
UserRecoveryEntity
(
)
,
'my-reset-url',
Context::
createDefaultContext
(
)
,
)
;
$storer
=
new
ScalarValuesStorer
(
)
;
$stored
=
$storer
->
store
(
$event
,
[
]
)
;
$flow
=
new
StorableFlow
(
'foo', Context::
createDefaultContext
(
)
,
$stored
)
;
$storer
->
restore
(
$flow
)
;
protected
function
setUp
(
)
: void
{
$this
->router =
$this
->
createMock
(
RouterInterface::
class
)
;
$this
->dispatcher =
$this
->
createMock
(
EventDispatcherInterface::
class
)
;
$this
->salesChannelContextService =
$this
->
createMock
(
SalesChannelContextService::
class
)
;
}
public
function
testGenerateUserRecoveryUserNotFound
(
)
: void
{
$userEmail
= 'nonexistent@example.com';
$context
=
new
Context
(
new
SystemSource
(
)
,
[
]
, Defaults::CURRENCY,
[
Defaults::LANGUAGE_SYSTEM
]
)
;
$recoveryEntity
=
new
UserRecoveryEntity
(
)
;
$recoveryEntity
->
setUniqueIdentifier
(
Uuid::
randomHex
(
)
)
;
/** @var StaticEntityRepository<UserCollection> $userRepository */
$userRepository
=
new
StaticEntityRepository
(
[
new
UserCollection
(
[
]
)
,
]
,
new
UserDefinition
(
)
)
;
/** @var StaticEntityRepository<UserRecoveryCollection> $recoveryRepository */
$recoveryRepository
=
new
StaticEntityRepository
(
[
new
UserRecoveryCollection
(
[
$recoveryEntity
]
)
,
new
UserRecoveryCollection
(
[
$recoveryEntity
]
)
,
]
,
$storable
=
new
StorableFlow
(
'name', Context::
createDefaultContext
(
)
)
;
$this
->storer->
restore
(
$storable
)
;
static
::
assertEmpty
(
$storable
->
data
(
)
)
;
}
public
function
testLoadEntity
(
)
: void
{
Feature::
skipTestIfActive
(
'v6.6.0.0',
$this
)
;
$entity
=
new
UserRecoveryEntity
(
)
;
$result
=
$this
->
createMock
(
EntitySearchResult::
class
)
;
$result
->
expects
(
static
::
once
(
)
)
->
method
(
'get'
)
->
willReturn
(
$entity
)
;
$this
->repository->
expects
(
static
::
once
(
)
)
->
method
(
'search'
)
->
willReturn
(
$result
)
;
$res
=
$this
->storer->
load
(
[
'3443', Context::
createDefaultContext
(
)
]
)
;
static
::
assertEquals
(
$res
,
$entity
)
;
}
public
function
testLoadNullEntity
(
)
: void
{