123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- /**
- * Tests for the Metatag module to ensure i18n integration doesn't break.
- */
- class MetatagCoreTermWithI18nTest extends MetatagTestHelper {
- /**
- * {@inheritdoc}
- */
- public static function getInfo() {
- return array(
- 'name' => 'Metatag core term tests with i18n',
- 'description' => 'Test Metatag taxonomy config integration with the i18n module.',
- 'group' => 'Metatag',
- 'dependencies' => array('ctools', 'token', 'i18n'),
- );
- }
- /**
- * {@inheritdoc}
- */
- function setUp(array $modules = array()) {
- // Need the i18n and i18n_strings modules.
- $modules[] = 'i18n';
- $modules[] = 'i18n_string';
- // Enable all of the modules that are needed.
- parent::setUp($modules);
- // Add more locales.
- $this->setupLocales();
- // Set up the locales.
- $perms = array(
- 'administer languages',
- 'translate interface',
- // From i18n.
- 'translate admin strings',
- 'translate user-defined strings',
- );
- $this->adminUser = $this->createAdminUser($perms);
- // Log in the admin user.
- $this->drupalLogin($this->adminUser);
- // Reload the translations.
- drupal_flush_all_caches();
- module_load_include('admin.inc', 'i18n_string');
- i18n_string_refresh_group('metatag');
- }
- /**
- * Test translations of the main taxonomy term configuration.
- */
- public function testI18nTermConfig() {
- // Plan out the different translation string tests.
- $string_en = 'It is a term page!';
- $config_name = 'metatag_config:taxonomy_term:title';
- // Confirm the translation page exists and has some Metatag strings.
- $this->searchTranslationPage('', $config_name);
- // Confirm the string is not present yet.
- $this->searchTranslationPage($string_en, $config_name, FALSE);
- // Load the meta tags.
- $instance = 'taxonomy_term';
- $config = metatag_config_load($instance);
- // Set something specific as the homepage.
- $config->config['title']['value'] = $string_en;
- metatag_config_save($config);
- // Confirm the string is present now.
- $this->searchTranslationPage($string_en, $config_name);
- // Get the translation string lid for the term's title.
- $lid = $this->getTranslationLidByContext($config_name);
- $this->assertNotEqual($lid, 0, 'Found the locales_source string for the taxonomy term title tag.');
- }
- /**
- * Test translations of the 'tags' vocabulary configuration.
- */
- public function testI18nTermTagsConfig() {
- // Plan out the different translation string tests.
- $string_en = 'It is a taxonomy term Tags page!';
- $config_name = 'metatag_config:taxonomy_term:tags:title';
- // Confirm the translation page exists and has some Metatag strings.
- $this->searchTranslationPage('', $config_name);
- // Confirm the string is not present yet.
- $this->searchTranslationPage($string_en, $config_name, FALSE);
- // Create a new config object for the taxonomy_term:tags structure.
- $config = new StdClass();
- $config->instance = 'taxonomy_term:tags';
- // Set an example tag.
- $config->config['title']['value'] = $string_en;
- metatag_config_save($config);
- // Confirm the string is present now.
- $this->searchTranslationPage($string_en, $config_name);
- // Get the translation string lid for the term's title.
- $lid = $this->getTranslationLidByContext($config_name);
- $this->assertNotEqual($lid, 0, 'Found the locales_source string for the taxonomy term title tag.');
- }
- }
|