You are here

protected function UnitTestBase::registerServiceWithContainerMock in Select (or other) 8

Same name and namespace in other branches
  1. 4.x tests/src/Unit/UnitTestBase.php \Drupal\Tests\select_or_other\Unit\UnitTestBase::registerServiceWithContainerMock()

Registers a (mocked) service with the mocked service container.

Parameters

string $service_id: The service id.

mixed $service: The service to be returned when the service_id is requested from the container.

4 calls to UnitTestBase::registerServiceWithContainerMock()
ListWidgetTest::massageFormValuesAddsNewValuesToAllowedValues in tests/src/Unit/ListWidgetTest.php
@test @covers Drupal\select_or_other\Plugin\Field\FieldWidget\ListWidget::extractNewValues @covers Drupal\select_or_other\Plugin\Field\FieldWidget\ListWidget::AddNewValuesToAllowedValues
ListWidgetTest::massageFormValuesDoNotAddOtherValuesToAllowedValues in tests/src/Unit/ListWidgetTest.php
@test @covers Drupal\select_or_other\Plugin\Field\FieldWidget\ListWidget::extractNewValues @covers Drupal\select_or_other\Plugin\Field\FieldWidget\ListWidget::AddNewValuesToAllowedValues
ReferenceWidgetTest::testIsApplicable in tests/src/Unit/ReferenceWidgetTest.php
Tests if the widget correctly determines if it is applicable.
UnitTestBase::addMockServicesToContainer in tests/src/Unit/UnitTestBase.php
Adds mocked services to the container.

File

tests/src/Unit/UnitTestBase.php, line 151

Class

UnitTestBase

Namespace

Drupal\Tests\select_or_other\Unit

Code

protected function registerServiceWithContainerMock($service_id, $service) {
  $this->services[$service_id] = $service;
}