Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
JsonException example
public
function
testUnableGenerateBundle
(
)
: void
{
$exception
= ApiException::
unableGenerateBundle
(
'bundleName'
)
;
static
::
assertEquals
(
ApiException::API_UNABLE_GENERATE_BUNDLE,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Unable to generate bundle directory for bundle "bundleName".',
$exception
->
getMessage
(
)
)
;
}
public
function
testInvalidSchemaDefinitions
(
)
: void
{
$exception
= ApiException::
invalidSchemaDefinitions
(
'file',
new
\
JsonException
(
)
)
;
static
::
assertEquals
(
ApiException::API_INVALID_SCHEMA_DEFINITION_EXCEPTION,
$exception
->
getErrorCode
(
)
)
;
}
public
function
testInvalidAccessKey
(
)
: void
{
$exception
= ApiException::
invalidAccessKey
(
)
;
static
::
assertEquals
(
ApiException::API_INVALID_ACCESS_KEY_EXCEPTION,
$exception
->
getErrorCode
(
)
)
;
}
use
Symfony\Component\HttpFoundation\Response;
/** * @internal * * @covers \Shopware\Core\Framework\Util\UtilException */
class
UtilExceptionTest
extends
TestCase
{
public
function
testInvalidJson
(
)
: void
{
$e
= UtilException::
invalidJson
(
$p
=
new
\
JsonException
(
'invalid'
)
)
;
static
::
assertEquals
(
Response::HTTP_BAD_REQUEST,
$e
->
getStatusCode
(
)
)
;
static
::
assertEquals
(
'UTIL_INVALID_JSON',
$e
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'JSON is invalid',
$e
->
getMessage
(
)
)
;
static
::
assertEquals
(
$p
,
$e
->
getPrevious
(
)
)
;
}
public
function
testInvalidJsonNotList
(
)
: void
{
$e
= UtilException::
invalidJsonNotList
(
)
;