You are here

protected function MigrateExecutableTest::getMockSource in Drupal 10

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

Returns a mock migration source instance.

Return value

\Drupal\migrate\Plugin\MigrateSourceInterface|\PHPUnit\Framework\MockObject\MockObject The mocked migration source.

File

core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php, line 379

Class

MigrateExecutableTest
@coversDefaultClass \Drupal\migrate\MigrateExecutable @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

protected function getMockSource() {
  $this
    ->createMock('\\Iterator');
  $class = 'Drupal\\migrate\\Plugin\\migrate\\source\\SourcePluginBase';
  $source = $this
    ->getMockBuilder($class)
    ->disableOriginalConstructor()
    ->onlyMethods(get_class_methods($class))
    ->getMockForAbstractClass();
  $source
    ->expects($this
    ->once())
    ->method('rewind')
    ->will($this
    ->returnValue(TRUE));
  $source
    ->expects($this
    ->any())
    ->method('initializeIterator')
    ->will($this
    ->returnValue([]));
  $source
    ->expects($this
    ->any())
    ->method('valid')
    ->will($this
    ->onConsecutiveCalls(TRUE, FALSE));
  return $source;
}