metatag.with_i18n_disabled.test 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * @file
  4. * Tests for Metatag for when i18n is enabled but not actually configured.
  5. */
  6. /**
  7. * Tests for Metatag for when i18n is enabled but not actually configured.
  8. */
  9. class MetatagCoreWithI18nDisabledTest extends MetatagTestHelper {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Metatag core tests with i18n disabled',
  16. 'description' => 'Test Metatag integration with the i18n module enabled but the integration disabled.',
  17. 'group' => 'Metatag',
  18. 'dependencies' => array('ctools', 'token', 'i18n'),
  19. );
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. function setUp(array $modules = array()) {
  25. // Need the i18n and i18n_strings modules.
  26. $modules[] = 'i18n';
  27. $modules[] = 'i18n_string';
  28. // Enable all of the modules that are needed.
  29. parent::setUp($modules);
  30. // Add more locales.
  31. $this->setupLocales();
  32. // Set up the locales.
  33. $perms = array(
  34. 'administer languages',
  35. 'translate interface',
  36. // From i18n.
  37. 'translate admin strings',
  38. 'translate user-defined strings',
  39. );
  40. $this->adminUser = $this->createAdminUser($perms);
  41. // Log in the admin user.
  42. $this->drupalLogin($this->adminUser);
  43. // Turn off i18n integration.
  44. variable_set('metatag_i18n_disabled', TRUE);
  45. // Reload the translations.
  46. drupal_flush_all_caches();
  47. module_load_include('admin.inc', 'i18n_string');
  48. i18n_string_refresh_group('metatag');
  49. }
  50. /**
  51. * Test translations of the output tags.
  52. */
  53. public function testI18nOutput() {
  54. // Plan out the different translation string tests.
  55. $string_en = 'Welcome to the homepage!';
  56. $string_fr = 'Bonjour pour le homepage!';
  57. $config_name = 'metatag:frontpage:title';
  58. $this->searchTranslationPage('', $config_name);
  59. // Confirm the string is not present yet.
  60. $this->searchTranslationPage($string_en, $config_name, FALSE);
  61. // Load the front page's meta tags.
  62. $instance = 'global:frontpage';
  63. $config = metatag_config_load($instance);
  64. // Set something specific as the homepage.
  65. $config->config['title']['value'] = $string_en;
  66. metatag_config_save($config);
  67. // Load the front page.
  68. $this->drupalGet('');
  69. $this->assertResponse(200, 'Loaded the homepage.');
  70. // Confirm the page's title is what we set it to.
  71. $this->assertTitle($string_en);
  72. // Confirm the string is still not translatable.
  73. $this->searchTranslationPage($string_en, $config_name, FALSE);
  74. // Get the translation string lid for the front page's title.
  75. $lid = $this->getTranslationLidByContext($config_name);
  76. $this->assertEqual($lid, 0, 'Did not find a locales_source string for the front page output title tag.');
  77. // Load the French front page.
  78. $this->drupalGet('fr');
  79. $this->assertResponse(200, 'Loaded the French homepage.');
  80. // Confirm the page's title is what we set it to.
  81. $this->assertTitle($string_en);
  82. }
  83. }