function MigrateSourceTest::testNextNeedsUpdate

Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testNextNeedsUpdate()
  2. 8.9.x core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testNextNeedsUpdate()
  3. 10 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 <a href="/api/drupal/core%21modules%21migrate%21src%21Plugin%21migrate%21source%21SourcePluginBase.php/class/SourcePluginBase/11.x" title="The base class for source plugins." class="local">\Drupal\migrate\Plugin\migrate\source\SourcePluginBase</a> @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testNextNeedsUpdate() : void {
    $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');
}

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