function UnitTestCase::getStringTranslationStub

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getStringTranslationStub()
  2. 10 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getStringTranslationStub()
  3. 9 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getStringTranslationStub()
  4. 8.9.x core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getStringTranslationStub()

Returns a stub translation manager that just returns the passed string.

Return value

\Drupal\Core\StringTranslation\TranslationManager A stub translation object.

88 calls to UnitTestCase::getStringTranslationStub()
BanAdminTest::testIpValidation in core/modules/ban/tests/src/Unit/BanAdminTest.php
Tests various user input to confirm correct validation.
BanAdminTest::testRouteParameter in core/modules/ban/tests/src/Unit/BanAdminTest.php
Test passing an IP address as a route parameter.
BanAdminTest::testSubmit in core/modules/ban/tests/src/Unit/BanAdminTest.php
Test form submission.
BaseFieldDefinitionTestBase::setUp in core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php
BlockManagerTest::setUp in core/tests/Drupal/Tests/Core/Block/BlockManagerTest.php

... See full list

File

core/tests/Drupal/Tests/UnitTestCase.php, line 126

Class

UnitTestCase
Provides a base class and helpers for Drupal unit tests.

Namespace

Drupal\Tests

Code

public function getStringTranslationStub() {
  // A TranslationManager without any translators added behaves as an
  // identity translator: \Drupal\Core\StringTranslation\TranslationManager::doTranslate()
  // falls back to the untranslated string whenever no translator supplies
  // a translation, so this reuses the real plural/translation logic
  // instead of duplicating it here.
  return new TranslationManager(new LanguageDefault([]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.