You are here

protected function StringTranslationTraitTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/StringTranslation/StringTranslationTraitTest.php \Drupal\Tests\Core\StringTranslation\StringTranslationTraitTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/StringTranslation/StringTranslationTraitTest.php, line 35

Class

StringTranslationTraitTest
@coversDefaultClass \Drupal\Core\StringTranslation\StringTranslationTrait @group StringTranslation

Namespace

Drupal\Tests\Core\StringTranslation

Code

protected function setUp() {
  $this->translation = $this
    ->getObjectForTrait('\\Drupal\\Core\\StringTranslation\\StringTranslationTrait');
  $mock = $this
    ->prophesize(TranslationInterface::class);
  $mock
    ->translate(Argument::cetera())
    ->shouldNotBeCalled();
  $mock
    ->formatPlural(Argument::cetera())
    ->shouldNotBeCalled();
  $mock
    ->translateString(Argument::cetera())
    ->will(function ($args) {
    return $args[0]
      ->getUntranslatedString();
  });
  $this->translation
    ->setStringTranslation($mock
    ->reveal());
  $this->reflection = new \ReflectionClass(get_class($this->translation));
}