Skip to content

Instantly share code, notes, and snippets.

@GoZOo
Last active July 28, 2017 12:35
Show Gist options
  • Save GoZOo/ff615d134deb73692ae91e5c24712e93 to your computer and use it in GitHub Desktop.
Save GoZOo/ff615d134deb73692ae91e5c24712e93 to your computer and use it in GitHub Desktop.
In a Drupal 8 PHPunit migration test, iterate on rows. Warning, if migration is previously executed, no iteration will be made.
<?php
function testMyMigration() {
$migration = $this->getMigration('MY_MIGRATION');
$source = $migration->getSourcePlugin();
$source->initializeIterator();
for ($i=0 ; $i < $source->count(); $i++) {
$source->rewind();
$row = $source->current();
$rows[] = $row;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment