Upgraded drupal core with security updates
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Block / BlockBaseTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Block;
4
5 use Drupal\block_test\Plugin\Block\TestBlockInstantiation;
6 use Drupal\Tests\UnitTestCase;
7
8 /**
9  * @coversDefaultClass \Drupal\Core\Block\BlockBase
10  * @group block
11  */
12 class BlockBaseTest extends UnitTestCase {
13
14   /**
15    * Tests the machine name suggestion.
16    *
17    * @see \Drupal\Core\Block\BlockBase::getMachineNameSuggestion()
18    */
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'])
24       ->getMock();
25
26     $config = [];
27     $definition = [
28       'admin_label' => 'Admin label',
29       'provider' => 'block_test',
30     ];
31     $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
32     $block_base->setTransliteration($transliteration);
33     $this->assertEquals('adminlabel', $block_base->getMachineNameSuggestion());
34
35     // Test with more unicodes.
36     $definition = [
37       'admin_label' => 'über åwesome',
38       'provider' => 'block_test',
39     ];
40     $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
41     $block_base->setTransliteration($transliteration);
42     $this->assertEquals('uberawesome', $block_base->getMachineNameSuggestion());
43   }
44
45 }