You are here

public function MigrateSourceTest::testNextNeedsUpdate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testNextNeedsUpdate()

Test that $row->needsUpdate() works as expected.

File

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

Class

MigrateSourceTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\source\SourcePluginBase @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testNextNeedsUpdate() {
  $source = $this
    ->getSource();

  // $row->needsUpdate() === TRUE so we get a row.
  $source
    ->rewind();
  $this
    ->assertTrue(is_a($source
    ->current(), 'Drupal\\migrate\\Row'), '$row->needsUpdate() is TRUE so we got a row.');

  // Test that we don't get a row when the incoming row is marked as imported.
  $source = $this
    ->getSource([], [], MigrateIdMapInterface::STATUS_IMPORTED);
  $source
    ->rewind();
  $this
    ->assertNull($source
    ->current(), 'Row was already imported, should be NULL');
}