You are here

public function QueueTest::testQueueCreation in Advanced Queue 8

Tests creating a queue.

File

tests/src/Functional/QueueTest.php, line 55

Class

QueueTest
Tests the queue UI.

Namespace

Drupal\Tests\advancedqueue\Functional

Code

public function testQueueCreation() {
  $this
    ->drupalGet('admin/config/system/queues');
  $this
    ->getSession()
    ->getPage()
    ->clickLink('Add queue');
  $this
    ->assertSession()
    ->addressEquals('admin/config/system/queues/add');
  $values = [
    'label' => 'Test',
    'configuration[database][lease_time]' => '200',
    'processor' => QueueInterface::PROCESSOR_DAEMON,
    'processing_time' => '100',
    // Setting the 'id' can fail if focus switches to another field.
    // This is a bug in the machine name JS that can be reproduced manually.
    'id' => 'test',
  ];
  $this
    ->submitForm($values, 'Save');
  $this
    ->assertSession()
    ->addressEquals('admin/config/system/queues');
  $this
    ->assertSession()
    ->responseContains('Test');
  $queue = Queue::load('test');
  $this
    ->assertEquals('test', $queue
    ->id());
  $this
    ->assertEquals('Test', $queue
    ->label());
  $this
    ->assertEquals('database', $queue
    ->getBackendId());
  $this
    ->assertEquals([
    'lease_time' => 200,
  ], $queue
    ->getBackendConfiguration());
  $this
    ->assertEquals($queue
    ->getBackendConfiguration(), $queue
    ->getBackend()
    ->getConfiguration());
  $this
    ->assertEquals(QueueInterface::PROCESSOR_DAEMON, $queue
    ->getProcessor());
  $this
    ->assertEquals(100, $queue
    ->getProcessingTime());
  $this
    ->assertFalse($queue
    ->isLocked());
}