BlockBaseTest.php in Drupal 8
File
core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php
View source
<?php
namespace Drupal\Tests\Core\Block;
use Drupal\block_test\Plugin\Block\TestBlockInstantiation;
use Drupal\Tests\UnitTestCase;
class BlockBaseTest extends UnitTestCase {
public function testGetMachineNameSuggestion($label, $expected) {
$module_handler = $this
->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
$transliteration = $this
->getMockBuilder('Drupal\\Core\\Transliteration\\PhpTransliteration')
->setConstructorArgs([
NULL,
$module_handler,
])
->setMethods([
'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());
}
public function providerTestGetMachineNameSuggestion() {
return [
[
'Admin label',
'adminlabel',
],
[
'über åwesome',
'uberawesome',
],
];
}
}