public function MakeUniqueEntityFieldTest::testMakeUniqueEntityField in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php \Drupal\Tests\migrate\Unit\process\MakeUniqueEntityFieldTest::testMakeUniqueEntityField()
- 9 core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php \Drupal\Tests\migrate\Unit\process\MakeUniqueEntityFieldTest::testMakeUniqueEntityField()
Tests making an entity field value unique.
@dataProvider providerTestMakeUniqueEntityField
File
- core/
modules/ migrate/ tests/ src/ Unit/ process/ MakeUniqueEntityFieldTest.php, line 67
Class
- MakeUniqueEntityFieldTest
- @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\MakeUniqueEntityField @group migrate
Namespace
Drupal\Tests\migrate\Unit\processCode
public function testMakeUniqueEntityField($count, $postfix = '', $start = NULL, $length = NULL) {
$configuration = [
'entity_type' => 'test_entity_type',
'field' => 'test_field',
];
if ($postfix) {
$configuration['postfix'] = $postfix;
}
$configuration['start'] = $start;
$configuration['length'] = $length;
$plugin = new MakeUniqueEntityField($configuration, 'make_unique', [], $this
->getMigration(), $this->entityTypeManager);
$this
->entityQueryExpects($count);
$value = $this
->randomMachineName(32);
$actual = $plugin
->transform($value, $this->migrateExecutable, $this->row, 'foo');
$expected = mb_substr($value, $start ?? 0, $length);
$expected .= $count ? $postfix . $count : '';
$this
->assertSame($expected, $actual);
}