You are here

protected function Select2Test::setUp in Select 2 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/Element/Select2Test.php, line 20

Class

Select2Test
@coversDefaultClass \Drupal\select2\Element\Select2 @group select2

Namespace

Drupal\Tests\select2\Unit\Element

Code

protected function setUp() {
  parent::setUp();
  $language = $this
    ->createMock('Drupal\\Core\\Language\\LanguageInterface');
  $language
    ->expects($this
    ->any())
    ->method('getDirection')
    ->will($this
    ->returnValue('rtl'));
  $language
    ->method('getId')
    ->will($this
    ->returnValue('en'));
  $language_manager = $this
    ->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
  $language_manager
    ->expects($this
    ->any())
    ->method('getCurrentLanguage')
    ->will($this
    ->returnValue($language));
  $theme = $this
    ->createMock('Drupal\\Core\\Theme\\ActiveTheme');
  $theme
    ->expects($this
    ->any())
    ->method('getName')
    ->will($this
    ->returnValue('seven'));
  $theme_manager = $this
    ->createMock('Drupal\\Core\\Theme\\ThemeManagerInterface');
  $theme_manager
    ->expects($this
    ->any())
    ->method('getActiveTheme')
    ->will($this
    ->returnValue($theme));
  $library_discovery = $this
    ->createMock('Drupal\\Core\\Asset\\LibraryDiscoveryInterface');
  $library_discovery
    ->expects($this
    ->any())
    ->method('getLibraryByName')
    ->will($this
    ->returnValue(TRUE));
  $string_translation = $this
    ->createMock('Drupal\\Core\\StringTranslation\\TranslationManager');
  $container = new ContainerBuilder();
  $container
    ->set('language_manager', $language_manager);
  $container
    ->set('theme.manager', $theme_manager);
  $container
    ->set('library.discovery', $library_discovery);
  $container
    ->set('string_translation', $string_translation);
  \Drupal::setContainer($container);
}