TranslationTest.php in Zircon Profile 8
File
core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php
View source
<?php
namespace Drupal\Tests\Core\Annotation;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
class TranslationTest extends UnitTestCase {
protected $translationManager;
protected function setUp() {
$this->translationManager = $this
->getStringTranslationStub();
}
public function testGet(array $values, $expected) {
$container = new ContainerBuilder();
$container
->set('string_translation', $this->translationManager);
\Drupal::setContainer($container);
$arguments = isset($values['arguments']) ? $values['arguments'] : array();
$options = isset($values['context']) ? array(
'context' => $values['context'],
) : array();
$annotation = new Translation($values);
$this
->assertSame($expected, (string) $annotation
->get());
}
public function providerTestGet() {
$data = array();
$data[] = array(
array(
'value' => 'Foo',
),
'Foo',
);
$random = $this
->randomMachineName();
$random_html_entity = '&' . $random;
$data[] = array(
array(
'value' => 'Foo @bar @baz %qux',
'arguments' => array(
'@bar' => $random,
'@baz' => $random_html_entity,
'%qux' => $random_html_entity,
),
'context' => $this
->randomMachineName(),
),
'Foo ' . $random . ' &' . $random . ' <em class="placeholder">&' . $random . '</em>',
);
return $data;
}
}