TestBlockInstantiation example

$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'],
    ];
Home | Imprint | This part of the site doesn't use cookies.