function BlockFormTest::getBlockMockWithMachineName

Same name and namespace in other branches
  1. 11.x core/modules/block/tests/src/Unit/BlockFormTest.php \Drupal\Tests\block\Unit\BlockFormTest::getBlockMockWithMachineName()
  2. 10 core/modules/block/tests/src/Unit/BlockFormTest.php \Drupal\Tests\block\Unit\BlockFormTest::getBlockMockWithMachineName()
  3. 9 core/modules/block/tests/src/Unit/BlockFormTest.php \Drupal\Tests\block\Unit\BlockFormTest::getBlockMockWithMachineName()
  4. 8.9.x core/modules/block/tests/src/Unit/BlockFormTest.php \Drupal\Tests\block\Unit\BlockFormTest::getBlockMockWithMachineName()

Mocks a block with a block plugin.

Parameters

string $machine_name: The machine name of the block plugin.

Return value

\Drupal\block\BlockInterface|\PHPUnit\Framework\MockObject\Stub The stub block.

1 call to BlockFormTest::getBlockMockWithMachineName()
BlockFormTest::testGetUniqueMachineName in core/modules/block/tests/src/Unit/BlockFormTest.php
Tests the unique machine name generator.

File

core/modules/block/tests/src/Unit/BlockFormTest.php, line 133

Class

BlockFormTest
Tests Drupal\block\BlockForm.

Namespace

Drupal\Tests\block\Unit

Code

protected function getBlockMockWithMachineName($machine_name) {
  $plugin = $this->createStub(BlockBase::class);
  $plugin->method('getMachineNameSuggestion')
    ->willReturn($machine_name);
  $block = $this->createStub(Block::class);
  $block->method('getPlugin')
    ->willReturn($plugin);
  return $block;
}

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