You are here

protected function MigrateEmbedMediaTokenTestBase::assertMediaTokenTransform in Media Migration 8

Asserts the result of Media Migration's embed media token transform.

Parameters

string|bool[][] $embed_code_html_properties: The expected attributes of the embed entity HTML tags, keyed by their delta (from their order in node with ID '1'). If a property value is set to TRUE, than this method checks only its existence. Example with teo expected embed code:

array(
  0 => array(
    'attribute-with-value' => 'value',
    'attribute-exists' => TRUE,
  ),
  1 => array(
    'attribute-with-value' => 'value',
    'attribute-exists' => TRUE,
  ),
);
2 calls to MigrateEmbedMediaTokenTestBase::assertMediaTokenTransform()
MigrateEmbedMediaTokenToEntityEmbedTest::testMediaTokenToEntityEmbedTransform in tests/src/Functional/MigrateEmbedMediaTokenToEntityEmbedTest.php
Tests the result of Media Migration's embed media token transform.
MigrateEmbedMediaTokenToMediaEmbedTest::testMediaTokenToMediaEmbedTransform in tests/src/Functional/MigrateEmbedMediaTokenToMediaEmbedTest.php
Tests the result of Media Migration's embed media token transform.

File

tests/src/Functional/MigrateEmbedMediaTokenTestBase.php, line 50

Class

MigrateEmbedMediaTokenTestBase
Base class for testing media token transformations.

Namespace

Drupal\Tests\media_migration\Functional

Code

protected function assertMediaTokenTransform(array $embed_code_html_properties) {
  $assert_session = $this
    ->assertSession();

  // Assert that media_filter plugin tokens were transformed to entity_embed
  // HTML entities, and the node can be viewed and edited without errors.
  $this
    ->drupalGet('node/1');
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->assertPageTitle('Article with embed image media');

  // The embed media' should be rendered properly.
  $this
    ->assertRenderedEmbedMedia();

  // Node can be edited.
  $this
    ->drupalGet('node/1/edit');
  $assert_session
    ->statusCodeEquals(200);

  // Node body text contains the expected HTML entity of the embed media.
  $body_textarea = $assert_session
    ->fieldExists('body[0][value]');
  $body_text = preg_replace('/\\s+/', ' ', $body_textarea
    ->getValue());
  $this
    ->assertEmbedTokenHtmlTags($body_text, $embed_code_html_properties);

  // Hitting save button should not cause errors.
  $this
    ->drupalPostForm(NULL, NULL, 'Save');
  $assert_session
    ->statusCodeEquals(200);

  // Url is node/1.
  $this
    ->assertSame($this
    ->buildUrl('node/1'), $this
    ->getUrl());

  // Embed media is still rendered.
  $this
    ->assertRenderedEmbedMedia();
}