function BlockBaseTest::testGetMachineNameSuggestion

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

Tests the machine name suggestion.

Attributes

#[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 34

Class

BlockBaseTest
Tests Drupal\Core\Block\BlockBase.

Namespace

Drupal\Tests\Core\Block

Code

public function testGetMachineNameSuggestion(string $label, string $expected) : void {
  $transliteration = new PhpTransliteration(NULL, $this->createStub(ModuleHandlerInterface::class));
  $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.