You are here

protected function MigrateExecutableTest::getMockSource in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::getMockSource()
  2. 10 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.

6 calls to MigrateExecutableTest::getMockSource()
MigrateExecutableTest::testImportWithValidRow in core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
Tests the import method with a valid row.
MigrateExecutableTest::testImportWithValidRowNoDestinationValues in core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
Tests the import method with a valid row.
MigrateExecutableTest::testImportWithValidRowWithDestinationMigrateException in core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
Tests the import method with a thrown MigrateException.
MigrateExecutableTest::testImportWithValidRowWithException in core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
Tests the import method with a regular Exception being thrown.
MigrateExecutableTest::testImportWithValidRowWithoutDestinationId in core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
Tests the import method with a valid row.

... See full list

File

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

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()
    ->setMethods(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;
}