You are here

public function EntityFileTest::testNonExistentSourceFile in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/file/src/Tests/Migrate/EntityFileTest.php \Drupal\file\Tests\Migrate\EntityFileTest::testNonExistentSourceFile()

Test that non-existent files throw an exception.

File

core/modules/file/src/Tests/Migrate/EntityFileTest.php, line 88
Contains \Drupal\file\Tests\Migrate\EntityFileTest.

Class

EntityFileTest
Tests the entity file destination plugin.

Namespace

Drupal\file\Tests\Migrate

Code

public function testNonExistentSourceFile() {
  $destination = '/non/existent/file';
  try {

    // If this test passes, doImport() will raise a MigrateException and
    // we'll never reach fail().
    $this
      ->doImport([
      'filepath' => $destination,
    ], 'public://wontmatter.jpg');
    $this
      ->fail('Expected Drupal\\migrate\\MigrateException when importing ' . $destination);
  } catch (MigrateException $e) {
    $this
      ->assertIdentical($e
      ->getMessage(), "File '{$destination}' does not exist.");
  }
}