You are here

public function BlockVisibilityTest::testTransformException in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php \Drupal\Tests\block\Unit\Plugin\migrate\process\BlockVisibilityTest::testTransformException()
  2. 9 core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php \Drupal\Tests\block\Unit\Plugin\migrate\process\BlockVisibilityTest::testTransformException()

@covers ::transform

File

core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php, line 89

Class

BlockVisibilityTest
Tests the block_visibility process plugin.

Namespace

Drupal\Tests\block\Unit\Plugin\migrate\process

Code

public function testTransformException() {
  $this->moduleHandler
    ->moduleExists('php')
    ->willReturn(FALSE);
  $migrate_lookup = $this
    ->prophesize(MigrateLookupInterface::class);
  $this->row = $this
    ->getMockBuilder('Drupal\\migrate\\Row')
    ->disableOriginalConstructor()
    ->onlyMethods([
    '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(), $migrate_lookup
    ->reveal());
  $this
    ->expectException(MigrateSkipRowException::class);
  $this
    ->expectExceptionMessage("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, 'destination_property');
}