Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block / tests / src / Unit / Plugin / migrate / process / BlockVisibilityTest.php
index 22b43b569bd845b9872f2a63b6f99d1adb9a2d79..9cb15523d1e4bbdf15a2200d0ada835ddbd3f81c 100644 (file)
@@ -4,6 +4,7 @@ namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
 
 use Drupal\block\Plugin\migrate\process\BlockVisibility;
 use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\migrate\MigrateSkipRowException;
 use Drupal\migrate\Plugin\MigrateProcessInterface;
 use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
 
@@ -80,4 +81,22 @@ class BlockVisibilityTest extends MigrateProcessTestCase {
     $this->assertEmpty($transformed_value);
   }
 
+  /**
+   * @covers ::transform
+   */
+  public function testTransformException() {
+    $this->moduleHandler->moduleExists('php')->willReturn(FALSE);
+    $migration_plugin = $this->prophesize(MigrateProcessInterface::class);
+    $this->row = $this->getMockBuilder('Drupal\migrate\Row')
+      ->disableOriginalConstructor()
+      ->setMethods(['getSourceProperty'])
+      ->getMock();
+    $this->row->expects($this->exactly(2))
+      ->method('getSourceProperty')
+      ->willReturnMap([['bid', 99], ['module', 'foobar']]);
+    $this->plugin = new BlockVisibility(['skip_php' => TRUE], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal());
+    $this->setExpectedException(MigrateSkipRowException::class, "The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration.");
+    $this->plugin->transform([2, '<?php', []], $this->migrateExecutable, $this->row, 'destinationproperty');
+  }
+
 }