3 namespace Drupal\Tests\video_embed_field\Functional;
4 use Drupal\Tests\BrowserTestBase;
7 * Test the autoplay permission works.
9 * @group video_embed_field
11 class AutoplayPermissionTest extends BrowserTestBase {
13 use EntityDisplaySetupTrait;
15 public static $modules = [
21 * Test the autoplay permission works.
23 public function testAutoplay() {
24 $this->setupEntityDisplays();
25 $node = $this->createVideoNode('https://vimeo.com/80896303');
26 $this->setDisplayComponentSettings('video_embed_field_video', [
29 $bypass_autoplay_user = $this->drupalCreateUser(['never autoplay videos']);
30 // Assert a user with the permission doesn't get autoplay.
31 $this->drupalLogin($bypass_autoplay_user);
32 $this->drupalGet('node/' . $node->id());
33 $this->assertSession()->elementAttributeContains('css', 'iframe', 'src', 'autoplay=0');
34 // Ensure an anonymous user gets autoplay.
35 $this->drupalLogout();
36 $this->drupalGet('node/' . $node->id());
37 $this->assertSession()->elementAttributeContains('css', 'iframe', 'src', 'autoplay=1');