diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php index 717abcce703..5e9e37a4b64 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php @@ -52,7 +52,7 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase { function testNodeTokenReplacement() { $url_options = array( 'absolute' => TRUE, - 'language' => $this->languageInterface, + 'language' => $this->interfaceLanguage, ); // Create a user and a node. @@ -82,14 +82,14 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase { $tests['[node:author]'] = String::checkPlain($account->getUsername()); $tests['[node:author:uid]'] = $node->getOwnerId(); $tests['[node:author:name]'] = String::checkPlain($account->getUsername()); - $tests['[node:created:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->languageInterface->id); - $tests['[node:changed:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->languageInterface->id); + $tests['[node:created:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->interfaceLanguage->id); + $tests['[node:changed:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->interfaceLanguage->id); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->languageInterface->id)); + $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced.', array('%token' => $input))); } @@ -101,7 +101,7 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase { $tests['[node:author:name]'] = $account->getUsername(); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->languageInterface->id, 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input))); } @@ -122,7 +122,7 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->languageInterface)); + $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage)); $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced for node without a summary.', array('%token' => $input))); } @@ -130,7 +130,7 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase { $tests['[node:summary]'] = $node->body->value; foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->languageInterface, 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced for node without a summary.', array('%token' => $input))); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php index 623d99592e2..4ea7da1fac0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php @@ -45,7 +45,7 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase { foreach ($tests as $test) { $input = $test['prefix'] . '[site:name]' . $test['suffix']; $expected = $test['prefix'] . 'Drupal' . $test['suffix']; - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->id)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->id)); $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input))); } @@ -66,12 +66,12 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase { // Replace with with the clear parameter, only the valid token should remain. $target = String::checkPlain(\Drupal::config('system.site')->get('name')); - $result = $this->tokenService->replace($source, array(), array('langcode' => $this->languageInterface->id, 'clear' => TRUE)); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->id, 'clear' => TRUE)); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); $target .= '[user:name]'; $target .= '[bogus:token]'; - $result = $this->tokenService->replace($source, array(), array('langcode' => $this->languageInterface->id)); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); } @@ -83,7 +83,7 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase { $this->installSchema('system', 'url_alias'); $url_options = array( 'absolute' => TRUE, - 'language' => $this->languageInterface, + 'language' => $this->interfaceLanguage, ); $slogan = 'Slogan'; @@ -111,7 +111,7 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->id)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($output, $expected, format_string('Sanitized system site information token %token replaced.', array('%token' => $input))); } @@ -120,7 +120,7 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase { $tests['[site:slogan]'] = $config->get('slogan'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->id, 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized system site information token %token replaced.', array('%token' => $input))); } @@ -146,18 +146,18 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase { // Generate and test tokens. $tests = array(); $date_service = \Drupal::service('date'); - $tests['[date:short]'] = $date_service->format($date, 'short', '', NULL, $this->languageInterface->id); - $tests['[date:medium]'] = $date_service->format($date, 'medium', '', NULL, $this->languageInterface->id); - $tests['[date:long]'] = $date_service->format($date, 'long', '', NULL, $this->languageInterface->id); - $tests['[date:custom:m/j/Y]'] = $date_service->format($date, 'custom', 'm/j/Y', NULL, $this->languageInterface->id); - $tests['[date:since]'] = $date_service->formatInterval(REQUEST_TIME - $date, 2, $this->languageInterface->id); + $tests['[date:short]'] = $date_service->format($date, 'short', '', NULL, $this->interfaceLanguage->id); + $tests['[date:medium]'] = $date_service->format($date, 'medium', '', NULL, $this->interfaceLanguage->id); + $tests['[date:long]'] = $date_service->format($date, 'long', '', NULL, $this->interfaceLanguage->id); + $tests['[date:custom:m/j/Y]'] = $date_service->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->id); + $tests['[date:since]'] = $date_service->formatInterval(REQUEST_TIME - $date, 2, $this->interfaceLanguage->id); $tests['[date:raw]'] = Xss::filter($date); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->languageInterface->id)); + $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php index c13bd4c33e1..c68f2e1fc97 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php @@ -20,7 +20,7 @@ abstract class TokenReplaceUnitTestBase extends EntityUnitTestBase { * * @var \Drupal\Core\Language\Language */ - protected $languageInterface; + protected $interfaceLanguage; /** * Token service. @@ -41,7 +41,7 @@ abstract class TokenReplaceUnitTestBase extends EntityUnitTestBase { // Install default system configuration. $this->installConfig(array('system')); - $this->languageInterface = \Drupal::languageManager()->getCurrentLanguage(); + $this->interfaceLanguage = \Drupal::languageManager()->getCurrentLanguage(); $this->tokenService = \Drupal::token(); }