You are here

public function PurgeTest::testQueueAndTablePurge in Acquia Content Hub 8.2

Tests queue and export table purging.

File

tests/src/Kernel/EventSubscriber/HandleWebhook/PurgeTest.php, line 123

Class

PurgeTest
Tests queue and export table purge.

Namespace

Drupal\Tests\acquia_contenthub\Kernel\EventSubscriber\HandleWebhook

Code

public function testQueueAndTablePurge() {

  // Before purge.
  $queue = $this->queueFactory
    ->get('acquia_contenthub_publish_export');
  $this
    ->assertGreaterThan(0, $queue
    ->numberOfItems());
  $this
    ->assertGreaterThan(0, $this
    ->getExportTableCount());
  $request = Request::createFromGlobals();
  $key = new Key('id', 'secret');
  $payload = [
    'crud' => 'purge',
    'status' => 'successful',
  ];
  $event = new HandleWebhookEvent($request, $payload, $key, $this->clientFactory
    ->getClient());
  $this->purge
    ->onHandleWebhook($event);

  // After purge.
  $this
    ->assertEqual(0, $queue
    ->numberOfItems());
  $this
    ->assertEqual(0, $this
    ->getExportTableCount());
}