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

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

File

core/modules/migrate/tests/src/Unit/MigrateSourceTest.php, line 233

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');
}