function ContentEntityTest::assertIds

Same name in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::assertIds()
  2. 8.9.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::assertIds()
  3. 11.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::assertIds()

Helper to assert IDs structure.

@internal

Parameters

\Drupal\migrate\Plugin\MigrateSourceInterface $source: The source plugin.

array $configuration: The source plugin configuration (Nope, no getter available).

5 calls to ContentEntityTest::assertIds()
ContentEntityTest::testFileSource in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php
Tests file source plugin.
ContentEntityTest::testMediaSource in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php
Tests media source plugin.
ContentEntityTest::testNodeSource in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php
Tests node source plugin.
ContentEntityTest::testTermSource in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php
Tests term source plugin.
ContentEntityTest::testUserSource in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php
Tests user source plugin.

File

core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php, line 193

Class

ContentEntityTest
Tests the entity content source plugin.

Namespace

Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source

Code

protected function assertIds(MigrateSourceInterface $source, array $configuration) : void {
    $ids = $source->getIds();
    [
        ,
        $entity_type_id,
    ] = explode(PluginBase::DERIVATIVE_SEPARATOR, $source->getPluginId());
    $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
    $this->assertArrayHasKey($entity_type->getKey('id'), $ids);
    $ids_count_expected = 1;
    if ($entity_type->isTranslatable()) {
        $ids_count_expected++;
        $this->assertArrayHasKey($entity_type->getKey('langcode'), $ids);
    }
    if ($entity_type->isRevisionable() && $configuration['add_revision_id']) {
        $ids_count_expected++;
        $this->assertArrayHasKey($entity_type->getKey('revision'), $ids);
    }
    $this->assertCount($ids_count_expected, $ids);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.