function LegacyBlockVisibilityTest::testTransformException

Tests Transform.

@covers ::transform

@expectedDeprecation Passing a migration process plugin as the fifth argument to Drupal\block\Plugin\migrate\process\BlockVisibility::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268

File

core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockVisibilityTest.php, line 119

Class

LegacyBlockVisibilityTest
Tests the block_visibility process plugin.

Namespace

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

Code

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->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, 'destinationproperty');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.