Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getUploadService example
#[Package('buyers-experience')]
class
StorefrontMediaUploaderTest
extends
TestCase
{
use
KernelTestBehaviour;
final
public
const
FIXTURE_DIR = __DIR__ . '/fixtures';
public
function
testUploadDocument
(
)
: void
{
$file
=
$this
->
getUploadFixture
(
'empty.pdf'
)
;
$result
=
$this
->
getUploadService
(
)
->
upload
(
$file
, 'test', 'documents', Context::
createDefaultContext
(
)
)
;
$repo
=
$this
->
getContainer
(
)
->
get
(
'media.repository'
)
;
static
::
assertEquals
(
1,
$repo
->
search
(
new
Criteria
(
[
$result
]
)
, Context::
createDefaultContext
(
)
)
->
getTotal
(
)
)
;
$this
->
removeMedia
(
$result
)
;
}
public
function
testUploadDocumentFailIllegalFileType
(
)
: void
{
$this
->
expectException
(
FileTypeNotAllowedException::
class
)
;
$this
->
expectExceptionMessage
(
(
new
FileTypeNotAllowedException
(
'application/vnd.ms-excel',