public function MigrateStubTest::testStubWithBundleFields in Drupal 10
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Kernel/MigrateStubTest.php \Drupal\Tests\migrate\Kernel\MigrateStubTest::testStubWithBundleFields()
Tests stub creation with bundle fields.
File
- core/
modules/ migrate/ tests/ src/ Kernel/ MigrateStubTest.php, line 107
Class
- MigrateStubTest
- Tests the migrate.stub Service.
Namespace
Drupal\Tests\migrate\KernelCode
public function testStubWithBundleFields() {
$this
->createContentType([
'type' => 'node_stub',
]);
// Make "Body" field required to make stubbing populate field value.
$body_field = FieldConfig::loadByName('node', 'node_stub', 'body');
$body_field
->setRequired(TRUE)
->save();
$this
->assertSame([], $this->migrateLookup
->lookup('sample_stubbing_migration', [
33,
]));
$ids = $this->migrateStub
->createStub('sample_stubbing_migration', [
33,
], []);
$this
->assertSame([
$ids,
], $this->migrateLookup
->lookup('sample_stubbing_migration', [
33,
]));
$node = \Drupal::entityTypeManager()
->getStorage('node')
->load($ids['nid']);
$this
->assertNotNull($node);
// Make sure the "Body" field value was populated.
$this
->assertNotEmpty($node
->get('body')->value);
}