Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getJpgWithFolder example
$this
->
expectExceptionMessage
(
MediaException::
thumbnailNotSupported
(
$media
->
getId
(
)
)
->
getMessage
(
)
)
;
$this
->thumbnailService->
updateThumbnails
(
$media
,
$this
->context,
false
)
;
}
public
function
testItUsesOriginalImageIfItsSmallerThanGeneratedThumbnail
(
)
: void
{
$this
->
setFixtureContext
(
$this
->context
)
;
$media
=
$this
->
getJpgWithFolder
(
)
;
$criteria
=
new
Criteria
(
[
$media
->
getId
(
)
]
)
;
$criteria
->
addAssociation
(
'mediaFolder.configuration.mediaThumbnailSizes'
)
;
/** @var MediaEntity $media */
$media
=
$this
->mediaRepository->
search
(
$criteria
,
$this
->context
)
->
get
(
$media
->
getId
(
)
)
;
static
::
assertInstanceOf
(
MediaFolderEntity::
class
,
$media
->
getMediaFolder
(
)
)
;
static
::
assertInstanceOf
(
MediaFolderConfigurationEntity::
class
,
$media
->
getMediaFolder
(
)
->
getConfiguration
(
)
)
;
$media
->
getMediaFolder
(
)
->
getConfiguration
(
)
->
setMediaThumbnailSizes
(
new
MediaThumbnailSizeCollection
(
[
(
$thumbnailPath
=
$this
->urlGenerator->
getRelativeThumbnailUrl
(
$media
,
$thumbnail
)
;
static
::
assertTrue
(
$this
->
getPublicFilesystem
(
)
->
has
(
$thumbnailPath
)
)
;
}
protected
function
createValidMediaFiles
(
)
: void
{
$this
->
setFixtureContext
(
$this
->context
)
;
$mediaPng
=
$this
->
getPngWithFolder
(
)
;
$mediaJpg
=
$this
->
getJpgWithFolder
(
)
;
$filePath
=
$this
->urlGenerator->
getRelativeMediaUrl
(
$mediaPng
)
;
$this
->
getPublicFilesystem
(
)
->
writeStream
(
$filePath
,
fopen
(
__DIR__ . '/../fixtures/shopware-logo.png', 'rb'
)
)
;
$filePath
=
$this
->urlGenerator->
getRelativeMediaUrl
(
$mediaJpg
)
;
$this
->
getPublicFilesystem
(
)
->
writeStream
(
$filePath
,
fopen
(
__DIR__ . '/../fixtures/shopware.jpg', 'rb'
)
)
;
$this
->
assertCacheBusterGenerator
(
$this
->
getUuidPathnameStrategy
(
)
)
;
}
public
function
testUuidFilename
(
)
: void
{
$this
->
assertFilenameGenerator
(
$this
->
getUuidPathnameStrategy
(
)
)
;
}
public
function
testUuidEncoding
(
)
: void
{
$this
->
assertHashGenerator
(
$this
->
getUuidPathnameStrategy
(
)
,
$this
->
getJpgWithFolder
(
)
, 8
)
;
$this
->
assertHashGenerator
(
$this
->
getUuidPathnameStrategy
(
)
,
$this
->
getJpg
(
)
, 8
)
;
$this
->
assertHashGenerator
(
$this
->
getUuidPathnameStrategy
(
)
,
$this
->
getTxt
(
)
, 8
)
;
}
public
function
testMd5CacheBuster
(
)
: void
{
$this
->
assertCacheBusterGenerator
(
$this
->
getMd5PathnameStrategy
(
)
)
;
}
public
function
testMd5Filename
(
)
: void
{
$folderId
= Uuid::
randomHex
(
)
;
$this
->
expectException
(
MediaException::
class
)
;
$this
->
expectExceptionMessage
(
MediaException::
mediaFolderIdNotFound
(
$folderId
)
->
getMessage
(
)
)
;
$this
->mediaFolderService->
dissolve
(
$folderId
,
$this
->context
)
;
}
public
function
testDissolveWithNoChildFolders
(
)
: void
{
$this
->
setFixtureContext
(
$this
->context
)
;
$media
=
$this
->
getJpgWithFolder
(
)
;
$mediaFolderId
=
$media
->
getMediaFolderId
(
)
;
static
::
assertIsString
(
$mediaFolderId
)
;
$mediaFolder
=
$this
->mediaFolderRepo
->
search
(
new
Criteria
(
array_filter
(
[
$mediaFolderId
]
)
)
,
$this
->context
)
->
get
(
$mediaFolderId
)
;
static
::
assertInstanceOf
(
MediaFolderEntity::
class
,
$mediaFolder
)
;
$configId
=
$mediaFolder
->
getConfigurationId
(
)
;