function MigrateEntityContentBaseTest::assertTranslations
Same name in other branches
- 8.9.x core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php \Drupal\Tests\migrate\Kernel\MigrateEntityContentBaseTest::assertTranslations()
- 10 core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php \Drupal\Tests\migrate\Kernel\MigrateEntityContentBaseTest::assertTranslations()
- 11.x core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php \Drupal\Tests\migrate\Kernel\MigrateEntityContentBaseTest::assertTranslations()
Check the existing translations of an entity.
@internal
Parameters
int $id: The entity ID.
string $default: The expected default translation language code.
string[] $others: The expected other translation language codes.
1 call to MigrateEntityContentBaseTest::assertTranslations()
- MigrateEntityContentBaseTest::testTranslated in core/
modules/ migrate/ tests/ src/ Kernel/ MigrateEntityContentBaseTest.php - Tests importing and rolling back translated entities.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ MigrateEntityContentBaseTest.php, line 77
Class
- MigrateEntityContentBaseTest
- Tests the EntityContentBase destination.
Namespace
Drupal\Tests\migrate\KernelCode
protected function assertTranslations(int $id, string $default, array $others = []) : void {
$entity = $this->storage
->load($id);
$this->assertNotEmpty($entity, "Entity exists");
$this->assertEquals($default, $entity->language()
->getId(), "Entity default translation");
$translations = array_keys($entity->getTranslationLanguages(FALSE));
sort($others);
sort($translations);
$this->assertEquals($others, $translations, "Entity translations");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.