TranslationMock.php in Plugin 8.2
File
tests/src/Unit/TranslationMock.php
View source
<?php
namespace Drupal\Tests\plugin\Unit;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\StringTranslation\TranslationInterface;
class TranslationMock implements TranslationInterface {
public function translate($string, array $args = array(), array $options = array()) {
return new TranslatableMarkup($string, $args, $options);
}
public function translateString(TranslatableMarkup $translatable_string) {
return new FormattableMarkup($translatable_string
->getUntranslatedString(), $translatable_string
->getArguments());
}
public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) {
return $count === 1 ? new FormattableMarkup($singular, $args) : new FormattableMarkup($plural, $args + [
'@count' => $count,
]);
}
public function formatPluralTranslated($count, $translation, array $args = array(), array $options = array()) {
return new FormattableMarkup($translation, $args);
}
public function getNumberOfPlurals($langcode = NULL) {
return mt_rand();
}
}