You are here

public function DemoImageTest::testTransformBadSourceFile in Panopoly 8.2

Tests that transform() throws an exception when a file is inaccessible.

@covers ::transform

@expectedException \Drupal\migrate\MigrateException @expectedExceptionMessage Cannot find source image: modules/demo_module/images/image.jpg

File

modules/panopoly/panopoly_core/tests/src/Unit/Plugin/migrate/process/DemoImageTest.php, line 210

Class

DemoImageTest
Tests for the 'panopoly_demo_image' migrate process plugin.

Namespace

Drupal\Tests\panopoly_core\Unit\Plugin\migrate\process

Code

public function testTransformBadSourceFile() {
  $executable = $this
    ->prophesize(MigrateExecutableInterface::class);
  $row = $this
    ->prophesize(Row::class);
  $row
    ->getSourceProperty('image_filename')
    ->willReturn('image.jpg');
  $plugin = $this
    ->createPlugin([
    'filename_property' => 'image_filename',
  ], [
    'getSourcePath',
    'getDestinationPath',
    'checkFile',
  ]);
  $plugin
    ->method('getSourcePath')
    ->willReturn('modules/demo_module/images');
  $plugin
    ->method('getDestinationPath')
    ->willReturn('public://demo_images');
  $plugin
    ->method('checkFile')
    ->willReturn(FALSE);
  $plugin
    ->transform(NULL, $executable
    ->reveal(), $row
    ->reveal(), 'field_image');
}