You are here

protected function SelectOrOtherWidgetBaseTest::setUp in Select (or other) 8.3

Overrides UnitTestCase::setUp

File

tests/src/Unit/SelectOrOtherWidgetBaseTest.php, line 36

Class

SelectOrOtherWidgetBaseTest
Tests the form element implementation.

Namespace

Drupal\tests\select_or_other\Unit

Code

protected function setUp() {
  parent::setUp();
  $container_class = 'Drupal\\Core\\DependencyInjection\\Container';
  $methods = get_class_methods($container_class);
  $this->containerMock = $this
    ->getMockBuilder($container_class)
    ->disableOriginalConstructor()
    ->setMethods($methods)
    ->getMock();
  \Drupal::setContainer($this->containerMock);
  $this->fieldDefinition = $this
    ->getMockForAbstractClass('\\Drupal\\Core\\Field\\FieldDefinitionInterface');
  $arguments = [
    '',
    '',
    $this->fieldDefinition,
    [],
    [],
  ];
  $this->widgetBaseMock = $this
    ->getMockForAbstractClass($this::$testedClassName, $arguments);

  /** @var SelectOrOtherWidgetBase $mock */
  $mock = $this->widgetBaseMock;
  $mock
    ->setStringTranslation($this
    ->getStringTranslationStub());
  $mock
    ->setSettings([]);
}