Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
cannotOpenSourceStreamToWrite example
/** * @throws MediaException * * @return resource */
private
function
openDestinationStream
(
string
$filename
)
{
try
{
$inputStream
= @
fopen
(
$filename
, 'wb'
)
;
}
catch
(
\Throwable
)
{
throw
MediaException::
cannotOpenSourceStreamToWrite
(
$filename
)
;
}
if
(
$inputStream
=== false
)
{
throw
MediaException::
cannotOpenSourceStreamToWrite
(
$filename
)
;
}
return
$inputStream
;
}
/** * @param resource $sourceStream * @param resource $destStream */
static
::
assertEquals
(
Response::HTTP_BAD_REQUEST,
$exception
->
getStatusCode
(
)
)
;
static
::
assertEquals
(
MediaException::MEDIA_CANNOT_OPEN_SOURCE_STREAM_TO_READ,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Cannot open source stream to read from http://invalid-url.',
$exception
->
getMessage
(
)
)
;
static
::
assertEquals
(
[
'url' =>
$url
]
,
$exception
->
getParameters
(
)
)
;
}
public
function
testCannotOpenSourceStreamToWrite
(
)
: void
{
$fileName
= 'invalid-filename';
$exception
= MediaException::
cannotOpenSourceStreamToWrite
(
$fileName
)
;
static
::
assertEquals
(
Response::HTTP_BAD_REQUEST,
$exception
->
getStatusCode
(
)
)
;
static
::
assertEquals
(
MediaException::MEDIA_CANNOT_OPEN_SOURCE_STREAM_TO_WRITE,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Cannot open source stream to write upload data: invalid-filename.',
$exception
->
getMessage
(
)
)
;
static
::
assertEquals
(
[
'fileName' =>
$fileName
]
,
$exception
->
getParameters
(
)
)
;
}
public
function
testCannotCopyMedia
(
)
: void
{
$exception
= MediaException::
cannotCopyMedia
(
)
;