StringTranslationTraitTest.php in Zircon Profile 8
File
core/tests/Drupal/Tests/Core/StringTranslation/StringTranslationTraitTest.php
View source
<?php
namespace Drupal\Tests\Core\StringTranslation;
use Drupal\Tests\UnitTestCase;
class StringTranslationTraitTest extends UnitTestCase {
protected $reflection;
protected $translation;
protected function setUp() {
$this->translation = $this
->getObjectForTrait('\\Drupal\\Core\\StringTranslation\\StringTranslationTrait');
$stub = $this
->getStringTranslationStub();
$stub
->expects($this
->any())
->method('formatPlural')
->will($this
->returnArgument(2));
$this->translation
->setStringTranslation($stub);
$this->reflection = new \ReflectionClass(get_class($this->translation));
}
public function testT() {
$method = $this->reflection
->getMethod('t');
$method
->setAccessible(TRUE);
$this
->assertEquals('something', $method
->invoke($this->translation, 'something'));
}
public function testFormatPlural() {
$method = $this->reflection
->getMethod('formatPlural');
$method
->setAccessible(TRUE);
$this
->assertEquals('apples', $method
->invoke($this->translation, 2, 'apple', 'apples'));
}
}