function MigrateExecutableTest::testImportWithFailingRewind
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testImportWithFailingRewind()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testImportWithFailingRewind()
- 11.x core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testImportWithFailingRewind()
Tests an import with an incomplete rewinding.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateExecutableTest.php, line 82
Class
- MigrateExecutableTest
- @coversDefaultClass \Drupal\migrate\MigrateExecutable @group migrate
Namespace
Drupal\Tests\migrate\UnitCode
public function testImportWithFailingRewind() : void {
$exception_message = $this->getRandomGenerator()
->string();
$source = $this->createMock('Drupal\\migrate\\Plugin\\MigrateSourceInterface');
$source->expects($this->once())
->method('rewind')
->will($this->throwException(new \Exception($exception_message)));
// The exception message contains the line number where it is thrown. Save
// it for the testing the exception message.
$line = __LINE__ - 3;
$this->migration
->expects($this->any())
->method('getSourcePlugin')
->willReturn($source);
// Ensure that a message with the proper message was added.
$exception_message .= " in " . __FILE__ . " line {$line}";
$this->message
->expects($this->once())
->method('display')
->with("Migration failed with source plugin exception: " . Html::escape($exception_message));
$result = $this->executable
->import();
$this->assertEquals(MigrationInterface::RESULT_FAILED, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.