createEmbedCode example

'alt' => 'pt-br alt',
        'title' => 'pt-br title',
      ])->save();
  }

  /** * Tests that the expected embedded media entity translation is selected. * * @dataProvider providerTranslationSituations */
  public function testTranslationSelection($text_langcode$expected_title_langcode) {
    $text = $this->createEmbedCode([
      'data-entity-type' => 'media',
      'data-entity-uuid' => static::EMBEDDED_ENTITY_UUID,
    ]);

    $result = $this->processText($text$text_langcode['media_embed']);
    $this->setRawContent($result->getProcessedText());

    $this->assertSame(
      $this->embeddedEntity->getTranslation($expected_title_langcode)->field_media_image->alt,
      (string) $this->cssSelect('img')[0]->attributes()['alt']
    );
    
$this->container->get('current_user')
      ->addRole($this->drupalCreateRole([
        'access contextual links',
      ]));
  }

  /** * @covers ::renderMedia * @covers ::disableContextualLinks */
  public function testDisabledIntegrations() {
    $text = $this->createEmbedCode([
      'data-entity-type' => 'media',
      'data-entity-uuid' => static::EMBEDDED_ENTITY_UUID,
    ]);

    $this->applyFilter($text);
    $this->assertCount(1, $this->cssSelect('div[data-media-embed-test-view-mode]'));
    $this->assertCount(0, $this->cssSelect('div[data-media-embed-test-view-mode].contextual-region'));
  }

}
// @see media_test_embed_entity_access()     // @see media_test_embed_entity_view_alter()     'media_test_embed',
  ];

  /** * Ensures media entities are rendered correctly. * * @dataProvider providerTestBasics */
  public function testBasics(array $embed_attributes$expected_view_mode, array $expected_attributes, CacheableMetadata $expected_cacheability) {
    $content = $this->createEmbedCode($embed_attributes);

    $result = $this->applyFilter($content);

    $this->assertCount(1, $this->cssSelect('div[data-media-embed-test-view-mode="' . $expected_view_mode . '"]'));
    $this->assertHasAttributes($this->cssSelect('div[data-media-embed-test-view-mode="' . $expected_view_mode . '"]')[0]$expected_attributes);
    $this->assertEqualsCanonicalizing($expected_cacheability->getCacheTags()$result->getCacheTags());
    $this->assertEqualsCanonicalizing($expected_cacheability->getCacheContexts()$result->getCacheContexts());
    $this->assertSame($expected_cacheability->getCacheMaxAge()$result->getCacheMaxAge());
    $this->assertSame(['library']array_keys($result->getAttachments()));
    $this->assertSame(['media/filter.caption']$result->getAttachments()['library']);
  }

  
Home | Imprint | This part of the site doesn't use cookies.