You are here

public function PluginTestBase::testDataStorageIntegrity in Purge 8.3

Test the data integrity of data stored in the queue.

File

tests/src/Kernel/Queue/PluginTestBase.php, line 55

Class

PluginTestBase
Provides a abstract test class to aid thorough tests for queue plugins.

Namespace

Drupal\Tests\purge\Kernel\Queue

Code

public function testDataStorageIntegrity() : void {
  $samples = [
    'a' => 'string',
    'b' => 'StrinG with Capitalization',
    'c' => 1,
    'd' => -1500,
    'e' => 0.15,
    'f' => -99999,
    'g' => NULL,
    'h' => FALSE,
    'i' => TRUE,
  ];

  // Test if we get back the exact same thing if we store it as scalar value.
  foreach ($samples as $sample) {
    $this->queue
      ->createItem($sample);
    $reference = $this->queue
      ->claimItem(3600);
    $this
      ->assertSame($reference->data, $sample);
  }

  // Test that we get the same data back by storing it in an object.
  $this->queue
    ->createItem($samples);
  $reference = $this->queue
    ->claimItem(3600);
  $this
    ->assertSame($reference->data, $samples);
  $this->queue
    ->deleteQueue();
}