View source
<?php
namespace Drupal\Tests\acquia_contenthub\Kernel;
class WebformSubmissionImportExportTest extends ImportExportTestBase {
protected $fixtures = [
[
'cdf' => 'webform_submission/webform-submission.json',
'expectations' => 'expectations/webform_submission/webform_submission.php',
],
];
public static $modules = [
'system',
'user',
'field',
'depcalc',
'acquia_contenthub',
'path_alias',
'webform',
];
public function setUp() {
parent::setUp();
$this
->installSchema('webform', [
'webform',
]);
$this
->installConfig('webform');
$this
->installEntitySchema('webform_submission');
$this
->installEntitySchema('user');
$this
->installSchema('user', [
'users_data',
]);
$this
->installEntitySchema('path_alias');
$this
->setUpCurrentUser();
static::$normalizeList[] = 'changed';
}
public function testWebformSubmissionImportExport($delta, $validate_data, $export_type, $export_uuid) {
parent::contentEntityImportExport($delta, $validate_data, $export_type, $export_uuid);
$fixtures = json_decode($this
->getFixtureString($delta), TRUE);
$submission_fixture_data = json_decode(base64_decode($fixtures['entities'][0]['metadata']['additional_data']['webform_elements']), TRUE);
$repository = \Drupal::service('entity.repository');
$submission = $repository
->loadEntityByUuid('webform_submission', $export_uuid);
$this
->assertEqual($submission_fixture_data, $submission
->getData(), "Submission data exported successfully.");
}
public function webformSubmissionImportExportDataProvider() {
return [
[
0,
[
[
'type' => 'webform_submission',
'uuid' => 'edd0127d-3cf0-49a5-9661-012449128145',
],
],
'webform_submission',
'edd0127d-3cf0-49a5-9661-012449128145',
],
];
}
}