From cc9f6173567816e091894e30b3cd5f9de4f9cd10 Mon Sep 17 00:00:00 2001
From: Dries <dries@buytaert.net>
Date: Tue, 5 Nov 2013 21:15:32 -0500
Subject: [PATCH] Issue #2120059 by jhedstrom: Cleanup temporary t() functions
 in phpunit tests.

---
 .../Core/Entity/EntityListController.php      |  8 +++----
 .../Tests/Plugin/Block/ViewsBlockTest.php     |  6 -----
 .../Drupal/views_ui/ViewListController.php    | 22 +++++++++----------
 .../views_ui/Tests/ViewListControllerTest.php | 15 ++-----------
 4 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php
index 7312e3f50b82..0a722a09fbe5 100644
--- a/core/lib/Drupal/Core/Entity/EntityListController.php
+++ b/core/lib/Drupal/Core/Entity/EntityListController.php
@@ -121,7 +121,7 @@ public function getOperations(EntityInterface $entity) {
     $operations = array();
     if ($entity->access('update')) {
       $operations['edit'] = array(
-        'title' => t('Edit'),
+        'title' => $this->t('Edit'),
         'href' => $uri['path'] . '/edit',
         'options' => $uri['options'],
         'weight' => 10,
@@ -129,7 +129,7 @@ public function getOperations(EntityInterface $entity) {
     }
     if ($entity->access('delete')) {
       $operations['delete'] = array(
-        'title' => t('Delete'),
+        'title' => $this->t('Delete'),
         'href' => $uri['path'] . '/delete',
         'options' => $uri['options'],
         'weight' => 100,
@@ -148,7 +148,7 @@ public function getOperations(EntityInterface $entity) {
    * @see \Drupal\Core\Entity\EntityListController::render()
    */
   public function buildHeader() {
-    $row['operations'] = t('Operations');
+    $row['operations'] = $this->t('Operations');
     return $row;
   }
 
@@ -203,7 +203,7 @@ public function render() {
       '#theme' => 'table',
       '#header' => $this->buildHeader(),
       '#rows' => array(),
-      '#empty' => t('There is no @label yet.', array('@label' => $this->entityInfo['label'])),
+      '#empty' => $this->t('There is no @label yet.', array('@label' => $this->entityInfo['label'])),
     );
     foreach ($this->load() as $entity) {
       if ($row = $this->buildRow($entity)) {
diff --git a/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php
index e94586fd0c2f..89e46aa71421 100644
--- a/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php
+++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php
@@ -150,13 +150,7 @@ public function testBuildFailed() {
 
 }
 
-// @todo Remove this once https://drupal.org/node/2018411 is in.
 namespace {
-  if (!function_exists('t')) {
-    function t($string) {
-      return $string;
-    }
-  }
   // @todo replace views_add_contextual_links()
   if (!function_exists('views_add_contextual_links')) {
     function views_add_contextual_links() {
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php
index d2029fe15b18..ef88707e7091 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php
@@ -104,7 +104,7 @@ public function buildRow(EntityInterface $view) {
         'path' => implode(', ', $this->getDisplayPaths($view)),
         'operations' => $row['operations'],
       ),
-      'title' => t('Machine name: @name', array('@name' => $view->id())),
+      'title' => $this->t('Machine name: @name', array('@name' => $view->id())),
       'class' => array($view->status() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'),
     );
   }
@@ -115,23 +115,23 @@ public function buildRow(EntityInterface $view) {
   public function buildHeader() {
     return array(
       'view_name' => array(
-        'data' => t('View name'),
+        'data' => $this->t('View name'),
         'class' => array('views-ui-name'),
       ),
       'description' => array(
-        'data' => t('Description'),
+        'data' => $this->t('Description'),
         'class' => array('views-ui-description'),
       ),
       'tag' => array(
-        'data' => t('Tag'),
+        'data' => $this->t('Tag'),
         'class' => array('views-ui-tag'),
       ),
       'path' => array(
-        'data' => t('Path'),
+        'data' => $this->t('Path'),
         'class' => array('views-ui-path'),
       ),
       'operations' => array(
-        'data' => t('Operations'),
+        'data' => $this->t('Operations'),
         'class' => array('views-ui-operations'),
       ),
     );
@@ -145,7 +145,7 @@ public function getOperations(EntityInterface $entity) {
     $uri = $entity->uri();
 
     $operations['clone'] = array(
-      'title' => t('Clone'),
+      'title' => $this->t('Clone'),
       'href' => $uri['path'] . '/clone',
       'options' => $uri['options'],
       'weight' => 15,
@@ -210,8 +210,8 @@ public function render() {
       ),
     );
 
-    $list['enabled']['heading']['#markup'] = '<h2>' . t('Enabled') . '</h2>';
-    $list['disabled']['heading']['#markup'] = '<h2>' . t('Disabled') . '</h2>';
+    $list['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled') . '</h2>';
+    $list['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled') . '</h2>';
     foreach (array('enabled', 'disabled') as $status) {
       $list[$status]['#type'] = 'container';
       $list[$status]['#attributes'] = array('class' => array('views-list-section', $status));
@@ -229,8 +229,8 @@ public function render() {
     }
     // @todo Use a placeholder for the entity label if this is abstracted to
     // other entity types.
-    $list['enabled']['table']['#empty'] = t('There are no enabled views.');
-    $list['disabled']['table']['#empty'] = t('There are no disabled views.');
+    $list['enabled']['table']['#empty'] = $this->t('There are no enabled views.');
+    $list['disabled']['table']['#empty'] = $this->t('There are no disabled views.');
 
     return $list;
   }
diff --git a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php
index 470568b0a373..b30bb341062f 100644
--- a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php
+++ b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php
@@ -5,8 +5,7 @@
  * Contains \Drupal\views_ui\Tests\ViewListControllerTest
  */
 
-namespace Drupal\views_ui\Tests {
-
+namespace Drupal\views_ui\Tests;
 
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Tests\UnitTestCase;
@@ -118,6 +117,7 @@ public function testBuildRowEntityList() {
     $executable_factory = new ViewExecutableFactory();
     $container->set('views.executable', $executable_factory);
     $container->set('plugin.manager.views.display', $display_manager);
+    $container->set('string_translation', $this->getStringTranslationStub());
     \Drupal::setContainer($container);
 
     $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
@@ -140,14 +140,3 @@ public function testBuildRowEntityList() {
   }
 
 }
-
-}
-
-// @todo Remove this once t() is converted to a service.
-namespace {
-  if (!function_exists('t')) {
-    function t($string) {
-      return $string;
-    }
-  }
-}
-- 
GitLab