3 namespace Drupal\Tests\Core\Block;
5 use Drupal\block_test\Plugin\Block\TestBlockInstantiation;
6 use Drupal\Tests\UnitTestCase;
9 * @coversDefaultClass \Drupal\Core\Block\BlockBase
12 class BlockBaseTest extends UnitTestCase {
15 * Tests the machine name suggestion.
17 * @see \Drupal\Core\Block\BlockBase::getMachineNameSuggestion()
19 public function testGetMachineNameSuggestion() {
20 $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
21 $transliteration = $this->getMockBuilder('Drupal\Core\Transliteration\PhpTransliteration')
22 ->setConstructorArgs([NULL, $module_handler])
23 ->setMethods(['readLanguageOverrides'])
28 'admin_label' => 'Admin label',
29 'provider' => 'block_test',
31 $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
32 $block_base->setTransliteration($transliteration);
33 $this->assertEquals('adminlabel', $block_base->getMachineNameSuggestion());
35 // Test with more unicodes.
37 'admin_label' => 'über åwesome',
38 'provider' => 'block_test',
40 $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
41 $block_base->setTransliteration($transliteration);
42 $this->assertEquals('uberawesome', $block_base->getMachineNameSuggestion());