You are here

protected function WebformMigrateAssertionsTrait::assertWebformSubmission1Values in Webform: Migrate 8

Same name and namespace in other branches
  1. 8.2 tests/src/Traits/WebformMigrateAssertionsTrait.php \Drupal\Tests\webform_migrate\Traits\WebformMigrateAssertionsTrait::assertWebformSubmission1Values()

Assertions of the webform_submission 1 content entity.

1 call to WebformMigrateAssertionsTrait::assertWebformSubmission1Values()
WebformMigrateTest::testWebformMigrations in tests/src/Kernel/Migrate/d7/WebformMigrateTest.php
Tests the migration of webforms and webform submissions.

File

tests/src/Traits/WebformMigrateAssertionsTrait.php, line 402

Class

WebformMigrateAssertionsTrait
Trait for webform migration tests.

Namespace

Drupal\Tests\webform_migrate\Traits

Code

protected function assertWebformSubmission1Values() {
  $webform_submission = $this->container
    ->get('entity_type.manager')
    ->getStorage('webform_submission')
    ->load(1);
  assert($webform_submission instanceof WebformSubmissionInterface);
  $this
    ->assertEquals([
    'uid' => [
      [
        'target_id' => 0,
      ],
    ],
    'created' => [
      [
        'value' => 1600263958,
      ],
    ],
    'serial' => [
      [
        'value' => 1,
      ],
    ],
    'sid' => [
      [
        'value' => 1,
      ],
    ],
    'uri' => [
      [
        'value' => '/node/3',
      ],
    ],
    'completed' => [
      [
        'value' => 1600263958,
      ],
    ],
    'in_draft' => [
      [
        'value' => 0,
      ],
    ],
    'current_page' => [],
    'remote_addr' => [
      [
        'value' => '::1',
      ],
    ],
    'webform_id' => [
      [
        'target_id' => 'webform_3',
      ],
    ],
    'entity_type' => [
      [
        'value' => 'node',
      ],
    ],
    'entity_id' => [
      [
        'value' => 3,
      ],
    ],
    'locked' => [
      [
        'value' => 0,
      ],
    ],
    'sticky' => [
      [
        'value' => 0,
      ],
    ],
    'notes' => [],
  ], $this
    ->getImportantEntityProperties($webform_submission));

  // Webform submission data.
  $data = $webform_submission
    ->getData();
  $this
    ->assertEquals([
    'checkboxes' => [
      'AF',
      'AL',
      'DZ',
      'AQ',
      'AG',
      'AR',
      'AU',
      'ZW',
    ],
    'date' => '2018-10-23',
    'file_attachment' => '1',
    'number' => '11',
    'radios' => 'sunday',
    'textarea' => 'Why I cannot choose Monday as my favorite weekday?',
    'time' => '18:01:00',
    'title_as_textfield' => 'Example submission from an anonymous user',
  ], $data);
}