You are here

public function BlockBaseTest::testGetMachineNameSuggestion in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php \Drupal\Tests\Core\Block\BlockBaseTest::testGetMachineNameSuggestion()

Tests the machine name suggestion.

See also

\Drupal\Core\Block\BlockBase::getMachineNameSuggestion().

File

core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php, line 24
Contains \Drupal\Tests\Core\Block\BlockBaseTest.

Class

BlockBaseTest
@coversDefaultClass \Drupal\Core\Block\BlockBase @group block

Namespace

Drupal\Tests\Core\Block

Code

public function testGetMachineNameSuggestion() {
  $module_handler = $this
    ->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $transliteration = $this
    ->getMockBuilder('Drupal\\Core\\Transliteration\\PhpTransliteration')
    ->setConstructorArgs(array(
    NULL,
    $module_handler,
  ))
    ->setMethods(array(
    'readLanguageOverrides',
  ))
    ->getMock();
  $config = array();
  $definition = array(
    'admin_label' => 'Admin label',
    'provider' => 'block_test',
  );
  $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
  $block_base
    ->setTransliteration($transliteration);
  $this
    ->assertEquals('adminlabel', $block_base
    ->getMachineNameSuggestion());

  // Test with more unicodes.
  $definition = array(
    'admin_label' => 'über åwesome',
    'provider' => 'block_test',
  );
  $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
  $block_base
    ->setTransliteration($transliteration);
  $this
    ->assertEquals('uberawesome', $block_base
    ->getMachineNameSuggestion());
}