Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
prepareImportExportProfileTestData example
$this
->repository =
$this
->
getContainer
(
)
->
get
(
'import_export_profile.repository'
)
;
$this
->connection =
$this
->
getContainer
(
)
->
get
(
Connection::
class
)
;
$this
->context = Context::
createDefaultContext
(
)
;
// Clean up system defaults before testing.
$this
->connection->
executeStatement
(
'DELETE FROM `import_export_profile`'
)
;
}
public
function
testImportExportProfileSingleCreateSuccess
(
)
: void
{
$data
=
$this
->
prepareImportExportProfileTestData
(
)
;
$id
=
array_key_first
(
$data
)
;
$this
->repository->
create
(
[
$data
[
$id
]
]
,
$this
->context
)
;
$record
=
$this
->connection->
fetchAssociative
(
'SELECT * FROM import_export_profile WHERE id = :id',
[
'id' =>
$id
]
)
;
$translationRecord
=
$this
->connection->
fetchAssociative
(
$this
->connection =
$this
->
getContainer
(
)
->
get
(
Connection::
class
)
;
$this
->context = Context::
createDefaultContext
(
)
;
// Clean up system defaults before testing.
$this
->connection->
executeStatement
(
'DELETE FROM `import_export_profile`'
)
;
}
public
function
testImportExportProfileCreateSuccess
(
)
: void
{
// prepare test data
$num
= 3;
$data
=
$this
->
prepareImportExportProfileTestData
(
$num
)
;
// do API calls
foreach
(
$data
as
$entry
)
{
$this
->
getBrowser
(
)
->
request
(
'POST',
$this
->
prepareRoute
(
)
,
[
]
,
[
]
,
[
]
,
json_encode
(
$entry
, \JSON_THROW_ON_ERROR
)
)
;
$response
=
$this
->
getBrowser
(
)
->
getResponse
(
)
;
static
::
assertSame
(
Response::HTTP_NO_CONTENT,
$response
->
getStatusCode
(
)
,
$response
->
getContent
(
)
)
;
}
// read created data from db
$records
=
$this
->connection->
fetchAllAssociative
(
'SELECT * FROM import_export_profile'
)
;
$translationRecords
=
$this
->
getTranslationRecords
(
)
;