function DedupeEntityTest::testDedupe

Tests entity based deduplication based on providerTestDedupe() values.

@dataProvider providerTestDedupe

File

core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php, line 65

Class

DedupeEntityTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\process\DedupeEntity @group migrate @group legacy

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testDedupe($count, $postfix = '', $start = NULL, $length = NULL) {
    $configuration = [
        'entity_type' => 'test_entity_type',
        'field' => 'test_field',
    ];
    if ($postfix) {
        $configuration['postfix'] = $postfix;
    }
    $configuration['start'] = isset($start) ? $start : NULL;
    $configuration['length'] = isset($length) ? $length : NULL;
    $plugin = new DedupeEntity($configuration, 'dedupe_entity', [], $this->getMigration(), $this->entityTypeManager);
    $this->entityQueryExpects($count);
    $value = $this->randomMachineName(32);
    $actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'testproperty');
    $expected = mb_substr($value, $start, $length);
    $expected .= $count ? $postfix . $count : '';
    $this->assertSame($expected, $actual);
}

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