function ContentEntityTest::testUserSource
Same name in other branches
- 9 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::testUserSource()
- 8.9.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::testUserSource()
- 10 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::testUserSource()
Tests user source plugin.
@dataProvider migrationConfigurationProvider
File
-
core/
modules/ migrate_drupal/ tests/ src/ Kernel/ Plugin/ migrate/ source/ ContentEntityTest.php, line 219
Class
- ContentEntityTest
- Tests the entity content source plugin.
Namespace
Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\sourceCode
public function testUserSource(array $configuration) : void {
$migration = $this->migrationPluginManager
->createStubMigration($this->migrationDefinition('content_entity:user', $configuration));
$user_source = $migration->getSourcePlugin();
$this->assertSame('users', $user_source->__toString());
if (!$configuration['include_translations']) {
// Confirm that the anonymous user is in the source database but not
// included in the rows returned by the content_entity.
$this->assertNotNull(User::load(0));
$this->assertEquals(1, $user_source->count());
}
$this->assertIds($user_source, $configuration);
$fields = $user_source->fields();
$this->assertArrayHasKey('name', $fields);
$this->assertArrayHasKey('pass', $fields);
$this->assertArrayHasKey('mail', $fields);
$this->assertArrayHasKey('uid', $fields);
$this->assertArrayHasKey('roles', $fields);
$user_source->rewind();
$values = $user_source->current()
->getSource();
$this->assertEquals('example@example.com', $values['mail'][0]['value']);
$this->assertEquals('user123', $values['name'][0]['value']);
$this->assertEquals(1, $values['uid']);
$this->assertEquals(1, $values['field_entity_reference'][0]['target_id']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.