You are here

public function MissingIdTest::testMissingId in Acquia Content Hub 8.2

Tests missing "Entity Id" functionality.

File

tests/src/Kernel/MissingIdTest.php, line 42

Class

MissingIdTest
Tests that entities without ids are not eligible for export.

Namespace

Drupal\Tests\acquia_contenthub\Kernel

Code

public function testMissingId() {

  // Create a webform.
  $webform = Webform::create([
    'id' => $this
      ->randomMachineName(),
  ]);
  $elements = [
    'name' => [
      '#type' => 'textfield',
      '#title' => 'name',
    ],
  ];
  $webform
    ->setElements($elements);

  // Disable saving of results.
  $webform
    ->setSetting('results_disabled', TRUE);
  $webform
    ->save();
  $pre_webform_submission_queue_count = $this->contentHubQueue
    ->getQueueCount();

  // Create a webform submission.
  $webform_submission = WebformSubmission::create([
    'id' => $this
      ->randomMachineName(),
    'webform_id' => $webform
      ->id(),
    'data' => [
      'name' => $this
        ->randomMachineName(),
    ],
  ]);
  $webform_submission
    ->save();
  $this
    ->assertEqual($this->contentHubQueue
    ->getQueueCount(), $pre_webform_submission_queue_count, 'Webform submission not queued.');
}