You are here

public function EntityQueueCrudTest::testEntityQueueCrud in Entityqueue 8

Tests CRUD operations for entity queue.

File

tests/src/Kernel/EntityQueueCrudTest.php, line 33

Class

EntityQueueCrudTest
Tests creation, loading, updating, deleting of entity queue.

Namespace

Drupal\Tests\entityqueue\Kernel

Code

public function testEntityQueueCrud() {
  $entity_queue = NULL;

  // Add a entity queue with minimum data only.
  foreach ([
    'simple',
    'multiple',
  ] as $handler) {
    foreach ([
      'node',
      'user',
    ] as $target_type) {
      $entity_queue = EntityQueue::create([
        'id' => $this
          ->randomMachineName(),
        'label' => $this
          ->randomString(),
        'handler' => $handler,
        'entity_settings' => [
          'target_type' => $target_type,
        ],
      ]);
      $entity_queue
        ->save();
      $this
        ->assetEntityQueue($entity_queue);
    }
  }
  $id = $entity_queue
    ->id();

  // Delete queue.
  $entity_queue
    ->delete();
  $this
    ->assertNull(EntityQueue::load($id));
}