You are here

public function EntityContentBaseTest::testUntranslatable in Drupal 8

Same name in this branch
  1. 8 core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\EntityContentBaseTest::testUntranslatable()
  2. 8 core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest::testUntranslatable()
Same name and namespace in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\EntityContentBaseTest::testUntranslatable()

Test that translation destination fails for untranslatable entities.

File

core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php, line 94

Class

EntityContentBaseTest
@group migrate_drupal

Namespace

Drupal\Tests\migrate_drupal\Kernel\d6

Code

public function testUntranslatable() {
  $this
    ->enableModules([
    'language_test',
  ]);
  $this
    ->installEntitySchema('no_language_entity_test');

  /** @var MigrationInterface $migration */
  $migration = \Drupal::service('plugin.manager.migration')
    ->createStubMigration([
    'source' => [
      'plugin' => 'embedded_data',
      'ids' => [
        'id' => [
          'type' => 'integer',
        ],
      ],
      'data_rows' => [
        [
          'id' => 1,
        ],
      ],
    ],
    'process' => [
      'id' => 'id',
    ],
    'destination' => [
      'plugin' => 'entity:no_language_entity_test',
      'translations' => TRUE,
    ],
  ]);
  $message = $this
    ->prophesize(MigrateMessageInterface::class);

  // Match the expected message. Can't use default argument types, because
  // we need to convert to string from TranslatableMarkup.
  $argument = Argument::that(function ($msg) {
    return strpos((string) $msg, htmlentities('The "no_language_entity_test" entity type does not support translations.')) !== FALSE;
  });
  $message
    ->display($argument, Argument::any())
    ->shouldBeCalled();
  $executable = new MigrateExecutable($migration, $message
    ->reveal());
  $executable
    ->import();
}