You are here

public function MigrateExecutableTest::testImportWithFailingRewind in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 62
Contains \Drupal\Tests\migrate\Unit\MigrateExecutableTest.

Class

MigrateExecutableTest
@coversDefaultClass \Drupal\Tests\migrate\Unit\MigrateExecutableTest @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testImportWithFailingRewind() {
  $exception_message = $this
    ->getRandomGenerator()
    ->string();
  $source = $this
    ->getMock('Drupal\\migrate\\Plugin\\MigrateSourceInterface');
  $source
    ->expects($this
    ->once())
    ->method('rewind')
    ->will($this
    ->throwException(new \Exception($exception_message)));
  $this->migration
    ->expects($this
    ->any())
    ->method('getSourcePlugin')
    ->will($this
    ->returnValue($source));

  // Ensure that a message with the proper message was added.
  $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);
}