// Process the queue item and make sure that the thumbnail was updated too.
$queue_name = 'media_entity_thumbnail';
/** @var \Drupal\Core\Queue\QueueWorkerInterface $queue_worker */
$queue_worker = \Drupal::
service('plugin.manager.queue_worker'
)->
createInstance($queue_name);
$queue = \Drupal::
queue($queue_name);
$this->
assertSame(1,
$queue->
numberOfItems(), 'Item was not added to the queue.'
);
$item =
$queue->
claimItem();
$this->
assertSame($media->
id(),
$item->data
['id'
], 'Queue item that was created does not belong to the correct entity.'
);
$queue_worker->
processItem($item->data
);
$queue->
deleteItem($item);
$this->
assertSame(0,
$queue->
numberOfItems(), 'Item was not removed from the queue.'
);
$media = Media::
load($media->
id());
$this->
assertSame('public://thumbnail1.jpg',
$media->thumbnail->entity->
getFileUri(), 'Thumbnail was not updated by the queue.'
);
$this->
assertEmpty($media->thumbnail->title
);
$this->
assertSame('',
$media->thumbnail->alt
);
// Set the alt metadata attribute and make sure it's used for the thumbnail.
\Drupal::
state()->
set('media_source_test_definition',
[ 'thumbnail_alt_metadata_attribute' => 'alt',
]);