You are here

protected function StubSourceGeneratorPlugin::initializeIterator in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\StubSourceGeneratorPlugin::initializeIterator()
  2. 9 core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\StubSourceGeneratorPlugin::initializeIterator()

Initializes the iterator with the source data.

Return value

\Iterator Returns an iterable object of data for this source.

Overrides StubSourcePlugin::initializeIterator

File

core/modules/migrate/tests/src/Unit/MigrateSourceTest.php, line 547
Contains \Drupal\Tests\migrate\Unit\MigrateSourceTest.

Class

StubSourceGeneratorPlugin
Stubbed source plugin with a generator as iterator. Also it overwrites the $skipCount, $cacheCounts and $trackChanges properties.

Namespace

Drupal\Tests\migrate\Unit

Code

protected function initializeIterator() {
  $data = [
    [
      'title' => 'foo',
    ],
    [
      'title' => 'bar',
    ],
    [
      'title' => 'iggy',
    ],
  ];
  foreach ($data as $row) {
    (yield $row);
  }
}