You are here

public function DeveloperSyncTest::testDeveloperAsync in Apigee Edge 8

Tests scheduled developer synchronization.

File

tests/src/Functional/DeveloperSyncTest.php, line 569

Class

DeveloperSyncTest
Developer-user synchronization test.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function testDeveloperAsync() {
  $this
    ->drupalGet(Url::fromRoute('apigee_edge.settings.developer.sync'));
  $this
    ->clickLinkProperly('Background');
  $this
    ->assertSession()
    ->pageTextContains('Developer synchronization is scheduled.');

  /** @var \Drupal\Core\Queue\QueueFactory $queue_service */
  $queue_service = $this->container
    ->get('queue');

  /** @var \Drupal\Core\Queue\QueueInterface $queue */
  $queue = $queue_service
    ->get('apigee_edge_job');

  /** @var \Drupal\Core\Queue\QueueWorkerManagerInterface $queue_worker_manager */
  $queue_worker_manager = $this->container
    ->get('plugin.manager.queue_worker');

  /** @var \Drupal\Core\Queue\QueueWorkerInterface $worker */
  $worker = $queue_worker_manager
    ->createInstance('apigee_edge_job');
  while ($item = $queue
    ->claimItem()) {
    $worker
      ->processItem($item->data);
    $queue
      ->deleteItem($item);
  }
  $this
    ->verify();
}