You are here

public function WebformSubmissionStorageTest::providerPurge in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Kernel/WebformSubmissionStorageTest.php \Drupal\Tests\webform\Kernel\WebformSubmissionStorageTest::providerPurge()

Data provider for testPurge().

See also

testPurge()

File

tests/src/Kernel/WebformSubmissionStorageTest.php, line 117

Class

WebformSubmissionStorageTest
Tests webform submission storage.

Namespace

Drupal\Tests\webform\Kernel

Code

public function providerPurge() {

  // The structure of each test case data is the following:
  // 0: (string) The webform 'purge' setting
  // 1: (array) Array of webform submissions to create in the webforms. It
  //    should be an array with the following structure:
  //    0: (bool) Whether it is a draft
  //    1: (bool) Whether the submission should be created in such time when
  //       that it becomes eligible for purging based on its creation time
  // 2: (array) Array of webform submission sequence IDs that should be purged
  //    in the test.
  $tests = [];

  // Test that only drafts are purged.
  $tests[] = [
    WebformSubmissionStorageInterface::PURGE_DRAFT,
    [
      [
        TRUE,
        TRUE,
      ],
      [
        TRUE,
        FALSE,
      ],
      [
        FALSE,
        TRUE,
      ],
      [
        FALSE,
        FALSE,
      ],
    ],
    [
      1,
    ],
  ];

  // Test that only completed submissions are purged.
  $tests[] = [
    WebformSubmissionStorageInterface::PURGE_COMPLETED,
    [
      [
        TRUE,
        TRUE,
      ],
      [
        TRUE,
        FALSE,
      ],
      [
        FALSE,
        TRUE,
      ],
      [
        FALSE,
        FALSE,
      ],
    ],
    [
      3,
    ],
  ];

  // Test that both completed and draft submissions are purged.
  $tests[] = [
    WebformSubmissionStorageInterface::PURGE_ALL,
    [
      [
        TRUE,
        TRUE,
      ],
      [
        TRUE,
        FALSE,
      ],
      [
        FALSE,
        TRUE,
      ],
      [
        FALSE,
        FALSE,
      ],
    ],
    [
      1,
      3,
    ],
  ];

  // Test the cron size parameter.
  $tests[] = [
    WebformSubmissionStorageInterface::PURGE_ALL,
    [
      [
        TRUE,
        TRUE,
      ],
      [
        TRUE,
        TRUE,
      ],
      [
        TRUE,
        FALSE,
      ],
      [
        FALSE,
        TRUE,
      ],
      [
        FALSE,
        FALSE,
      ],
    ],
    [
      1,
      2,
    ],
  ];
  return $tests;
}