function ContentEntityTest::testFileSource
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::testFileSource()
- 10 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::testFileSource()
- 11.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::testFileSource()
Tests file source plugin.
@dataProvider migrationConfigurationProvider
File
-
core/
modules/ migrate_drupal/ tests/ src/ Kernel/ Plugin/ migrate/ source/ ContentEntityTest.php, line 298
Class
- ContentEntityTest
- Tests the entity content source plugin.
Namespace
Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\sourceCode
public function testFileSource(array $configuration) {
$file = File::create([
'filename' => 'foo.txt',
'uid' => $this->user
->id(),
'uri' => 'public://foo.txt',
]);
$file->save();
$migration = $this->migrationPluginManager
->createStubMigration($this->migrationDefinition('content_entity:file', $configuration));
$file_source = $migration->getSourcePlugin();
$this->assertSame('files', $file_source->__toString());
if (!$configuration['include_translations']) {
$this->assertEquals(1, $file_source->count());
}
$this->assertIds($file_source, $configuration);
$fields = $file_source->fields();
$this->assertArrayHasKey('fid', $fields);
$this->assertArrayHasKey('filemime', $fields);
$this->assertArrayHasKey('filename', $fields);
$this->assertArrayHasKey('uid', $fields);
$this->assertArrayHasKey('uri', $fields);
$file_source->rewind();
$values = $file_source->current()
->getSource();
$this->assertEquals('text/plain', $values['filemime'][0]['value']);
$this->assertEquals('public://foo.txt', $values['uri'][0]['value']);
$this->assertEquals('foo.txt', $values['filename'][0]['value']);
$this->assertEquals(1, $values['fid']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.