function BlockVisibilityTest::testTransformException

Same name in other branches
  1. 9 core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php \Drupal\Tests\block\Unit\Plugin\migrate\process\BlockVisibilityTest::testTransformException()
  2. 8.9.x core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php \Drupal\Tests\block\Unit\Plugin\migrate\process\BlockVisibilityTest::testTransformException()
  3. 11.x 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 91

Class

BlockVisibilityTest
Tests the block_visibility process plugin.

Namespace

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

Code

public function testTransformException() : void {
    $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');
}

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