metatag.with_i18n_disabled.test 2.8 KB

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