Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ProductDownloadEntity example
'id' => Uuid::
randomHex
(
)
,
]
,
]
;
$payload
=
$this
->loader->
load
(
$lineItems
, Context::
createDefaultContext
(
)
)
;
static
::
assertEquals
(
[
]
,
$payload
)
;
}
public
function
testNoPayloadContinue
(
)
: void
{
$productDownload
=
new
ProductDownloadEntity
(
)
;
$productDownload
->
setId
(
Uuid::
randomHex
(
)
)
;
$productDownload
->
setProductId
(
Uuid::
randomHex
(
)
)
;
$entitySearchResult
=
$this
->
createMock
(
EntitySearchResult::
class
)
;
$entitySearchResult
->
method
(
'getEntities'
)
->
willReturn
(
new
EntityCollection
(
[
$productDownload
]
)
)
;
$this
->productDownloadRepository
->
expects
(
static
::
once
(
)
)
->
method
(
'search'
)
->
willReturn
(
$entitySearchResult
)
;
$lineItems
=
[
[
new
EntitySearchResult
(
'orderAddress',
1,
new
EntityCollection
(
$orderAddressRepositoryResultArray
)
,
null,
new
Criteria
(
)
,
Context::
createDefaultContext
(
)
)
)
;
}
$productDownload
=
new
ProductDownloadEntity
(
)
;
$productDownload
->
setId
(
Uuid::
randomHex
(
)
)
;
$productDownload
->
setMediaId
(
Uuid::
randomHex
(
)
)
;
$productDownload
->
setPosition
(
0
)
;
$productDownloadRepository
=
$this
->
createMock
(
EntityRepository::
class
)
;
$productDownloadRepository
->
method
(
'search'
)
->
willReturnCallback
(
function
DCriteria
$criteria
)
use
(
$productDownload
)
: EntitySearchResult
{
$filters
=
$criteria
->
getFilters
(
)
;
if
(
isset
(
$filters
[
0
]
)
&&
$filters
[
0
]
instanceof EqualsAnyFilter
)
{
$value
= ReflectionHelper::
getPropertyValue
(
$filters
[
0
]
, 'value'
)
;
$productDownload
->
setProductId
(
$value
[
0
]
?? null
)
;
}