function BlockFormTest::getBlockMockWithMachineName
Same name in other branches
- 9 core/modules/block/tests/src/Unit/BlockFormTest.php \Drupal\Tests\block\Unit\BlockFormTest::getBlockMockWithMachineName()
- 8.9.x core/modules/block/tests/src/Unit/BlockFormTest.php \Drupal\Tests\block\Unit\BlockFormTest::getBlockMockWithMachineName()
- 11.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\MockObject The mocked 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 123
Class
- BlockFormTest
- @coversDefaultClass \Drupal\block\BlockForm @group block
Namespace
Drupal\Tests\block\UnitCode
protected function getBlockMockWithMachineName($machine_name) {
$plugin = $this->getMockBuilder(BlockBase::class)
->disableOriginalConstructor()
->getMock();
$plugin->expects($this->any())
->method('getMachineNameSuggestion')
->willReturn($machine_name);
$block = $this->getMockBuilder(Block::class)
->disableOriginalConstructor()
->getMock();
$block->expects($this->any())
->method('getPlugin')
->willReturn($plugin);
return $block;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.