diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index a064d01..8a55c25 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -178,6 +178,13 @@ protected $curlCookies = array(); /** + * An array of custom translations suitable for drupal_rewrite_settings(). + * + * @var array + */ + protected $customTranslations; + + /** * Constructor for \Drupal\simpletest\WebTestBase. */ function __construct($test_id = NULL) { @@ -918,6 +925,41 @@ protected function writeSettings($settings) { } /** + * Adds custom translations. + * + * @param string $langcode + * The langcode to add translations for. + * @param array $values + * Array of values containing the untranslated string and its translation. + * For example: + * @code + * array( + * '' => array('Sunday' => 'domingo'), + * 'Long month name' => array('March' => 'marzo'), + * ); + * @endcode + */ + protected function addCustomTranslations($langcode, array $values) { + $this->settingsSet('locale_custom_strings_' . $langcode, $values); + foreach ($values as $key => $translations) { + foreach ($translations as $label => $value) { + $this->customTranslations['locale_custom_strings_' . $langcode][$key][$label] = (object) array( + 'value' => $value, + 'required' => TRUE, + ); + } + } + } + + /** + * Writes custom translations to test site's settings.php. + */ + protected function writeCustomTranslations() { + $this->writeSettings(array('settings' => $this->customTranslations)); + $this->customTranslations = array(); + } + + /** * Overrides \Drupal\simpletest\TestBase::rebuildContainer(). */ protected function rebuildContainer() { diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php index 8c41c4d..f341681 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php @@ -7,12 +7,12 @@ namespace Drupal\system\Tests\Menu; -use Drupal\system\Tests\System\CustomStringsTestBase; +use Drupal\simpletest\WebTestBase; /** * Tests menu router and hook_menu() functionality. */ -class MenuRouterTest extends CustomStringsTestBase { +class MenuRouterTest extends WebTestBase { /** * Modules to enable. diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php index 4e1dadf..34e3889 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php @@ -9,12 +9,12 @@ use Drupal\Core\Language\Language; use Drupal\plugin_test\Plugin\CachedMockBlockManager; -use Drupal\system\Tests\System\CustomStringsTestBase; +use Drupal\simpletest\WebTestBase; /** * Tests that the AlterDecorator fires and respects the alter hook. */ -class CacheDecoratorLanguageTest extends CustomStringsTestBase { +class CacheDecoratorLanguageTest extends WebTestBase { /** * Modules to enable. diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CustomStringsTestBase.php b/core/modules/system/lib/Drupal/system/Tests/System/CustomStringsTestBase.php deleted file mode 100644 index 1a56c9e..0000000 --- a/core/modules/system/lib/Drupal/system/Tests/System/CustomStringsTestBase.php +++ /dev/null @@ -1,59 +0,0 @@ - array('Sunday' => 'domingo'), - * 'Long month name' => array('March' => 'marzo'), - * ); - * @endcode - */ - protected function addCustomTranslations($langcode, array $values) { - $this->settingsSet('locale_custom_strings_' . $langcode, $values); - foreach ($values as $key => $translations) { - foreach ($translations as $label => $value) { - $this->customTranslations['locale_custom_strings_' . $langcode][$key][$label] = (object) array( - 'value' => $value, - 'required' => TRUE, - ); - } - } - } - - /** - * Writes custom translations to test site's settings.php. - */ - protected function writeCustomTranslations() { - $this->writeSettings(array('settings' => $this->customTranslations)); - $this->customTranslations = array(); - } - -}