diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php new file mode 100644 index 0000000..91eeaf3 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php @@ -0,0 +1,75 @@ +translationManager = $this->getStringTranslationStub(); + $container = new ContainerBuilder(); + $container->set('string_translation', $this->translationManager); + \Drupal::setContainer($container); + } + + /** + * @covers ::__construct + * @covers ::__toString + * @covers ::render + * + * @dataProvider providerTestConstruction + */ + public function testConstruction($expected, $string, $options = []) { + + $this->translationManager->expects($this->exactly(2)) + ->method('translate') + ->with($string, [], $options); + + $wrapper = new TranslationWrapper($string, $options); + + $this->assertSame($expected, (string) $wrapper); + $this->assertSame($expected, $wrapper->render()); + } + + /** + * Provides data to self::testConstruction(). + */ + public function providerTestConstruction() { + $data = array(); + $data[] = array( + 'Foo', + 'Foo', + ); + + $data[] = array( + 'Foo', + 'Foo', + ['context' => 'Bar'], + ); + + return $data; + } + +}