class BlockBaseTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Block/BlockBaseTest.php \Drupal\KernelTests\Core\Block\BlockBaseTest
- 11.x core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php \Drupal\Tests\Core\Block\BlockBaseTest
- 10 core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php \Drupal\Tests\Core\Block\BlockBaseTest
- 8.9.x core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php \Drupal\Tests\Core\Block\BlockBaseTest
@coversDefaultClass \Drupal\Core\Block\BlockBase
@group block
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Block\BlockBaseTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of BlockBaseTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Block/ BlockBaseTest.php, line 12
Namespace
Drupal\Tests\Core\BlockView source
class BlockBaseTest extends UnitTestCase {
/**
* Tests the machine name suggestion.
*
* @see \Drupal\Core\Block\BlockBase::getMachineNameSuggestion()
*
* @param string $label
* The block label.
* @param string $expected
* The expected machine name.
*
* @dataProvider providerTestGetMachineNameSuggestion()
*/
public function testGetMachineNameSuggestion($label, $expected) {
$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());
}
/**
* Provides data for testGetMachineNameSuggestion().
*/
public function providerTestGetMachineNameSuggestion() {
return [
[
'Admin label',
'adminlabel',
],
[
'über åwesome',
'uberawesome',
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.