Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createThumbnailWithMedia example
use
QueueTestBehaviour;
/** * @dataProvider deleteThumbnailProvider */
public
function
testDeleteThumbnail
(
bool
$private
)
: void
{
$service
=
$private
? 'shopware.filesystem.private' : 'shopware.filesystem.public';
$mediaId
= Uuid::
randomHex
(
)
;
$media
=
$this
->
createThumbnailWithMedia
(
$mediaId
,
$private
)
;
$thumbnailPath
=
$this
->
createThumbnailFile
(
$media
,
$service
)
;
$thumbnailIds
=
$this
->
getContainer
(
)
->
get
(
'media_thumbnail.repository'
)
->
searchIds
(
new
Criteria
(
)
, Context::
createDefaultContext
(
)
)
;
$delete
= \
array_values
(
\
array_map
(
static
fn
(
$id
)
=>
[
'id' =>
$id
]
,
$thumbnailIds
->
getIds
(
)
)
)
;
$this
->
getContainer
(
)
->
get
(
'media_thumbnail.repository'
)
->
delete
(
$delete
, Context::
createDefaultContext
(
)
)
;
$this
->
runWorker
(
)
;