function BlockBaseTest::testGetMachineNameSuggestion

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php \Drupal\Tests\Core\Block\BlockBaseTest::testGetMachineNameSuggestion()
  2. 8.9.x core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php \Drupal\Tests\Core\Block\BlockBaseTest::testGetMachineNameSuggestion()
  3. 10 core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php \Drupal\Tests\Core\Block\BlockBaseTest::testGetMachineNameSuggestion()

Tests the machine name suggestion.

@dataProvider providerTestGetMachineNameSuggestion

Parameters

string $label: The block label.

string $expected: The expected machine name.

See also

\Drupal\Core\Block\BlockBase::getMachineNameSuggestion()

File

core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php, line 30

Class

BlockBaseTest
@coversDefaultClass \Drupal\Core\Block\BlockBase @group block

Namespace

Drupal\Tests\Core\Block

Code

public function testGetMachineNameSuggestion($label, $expected) : void {
    $module_handler = $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
    $transliteration = $this->getMockBuilder('Drupal\\Core\\Transliteration\\PhpTransliteration')
        ->setConstructorArgs([
        NULL,
        $module_handler,
    ])
        ->onlyMethods([
        'readLanguageOverrides',
    ])
        ->getMock();
    $config = [];
    $definition = [
        'admin_label' => $label,
        'provider' => 'block_test',
    ];
    $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
    $block_base->setTransliteration($transliteration);
    $this->assertEquals($expected, $block_base->getMachineNameSuggestion());
}

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