Projet

Général

Profil

Paste
Télécharger (3,8 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds / tests / feeds_i18n_taxonomy.test @ ed9a13f1

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains Feedsi18nTaxonomyTestCase.
6
 */
7

    
8
/**
9
 * Tests importing terms in a language.
10
 */
11
class Feedsi18nTaxonomyTestCase extends Feedsi18nTestCase {
12

    
13
  /**
14
   * Name of created vocabulary.
15
   *
16
   * @var string
17
   */
18
  private $vocabulary;
19

    
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public static function getInfo() {
24
    return array(
25
      'name' => 'Multilingual terms',
26
      'description' => 'Tests Feeds multilingual support for taxonomy terms.',
27
      'group' => 'Feeds',
28
      'dependencies' => array('locale', 'i18n_taxonomy'),
29
    );
30
  }
31

    
32
  /**
33
   * {@inheritdoc}
34
   */
35
  public function setUp($modules = array(), $permissions = array()) {
36
    $this->entityType = 'taxonomy_term';
37
    $this->processorName = 'FeedsTermProcessor';
38

    
39
    $modules = array_merge($modules, array(
40
      'i18n_taxonomy',
41
    ));
42
    parent::setUp($modules, $permissions);
43

    
44
    // Create vocabulary.
45
    $this->vocabulary = strtolower($this->randomName(8));
46
    $edit = array(
47
      'name' => $this->vocabulary,
48
      'machine_name' => $this->vocabulary,
49
    );
50
    $this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
51

    
52
    // Configure importer.
53
    $this->setSettings('i18n', $this->processorName, array(
54
      'bundle' => $this->vocabulary,
55
      'language' => 'de',
56
      'update_existing' => FEEDS_UPDATE_EXISTING,
57
      'skip_hash_check' => TRUE,
58
    ));
59
    $this->addMappings('i18n', array(
60
      0 => array(
61
        'source' => 'guid',
62
        'target' => 'guid',
63
        'unique' => '1',
64
      ),
65
      1 => array(
66
        'source' => 'title',
67
        'target' => 'name',
68
      ),
69
    ));
70
  }
71

    
72
  /**
73
   * Tests if the language setting is available on the processor.
74
   */
75
  public function testAvailableProcessorLanguageSetting() {
76
    // Check if the language setting is available when the i18n_taxonomy module is enabled.
77
    $this->drupalGet('admin/structure/feeds/i18n/settings/FeedsTermProcessor');
78
    $this->assertField('language', 'Language field is available on the term processor settings when the i18n_taxonomy module is enabled.');
79

    
80
    // Disable the i18n_taxonomy module and check if the language setting is no longer available.
81
    module_disable(array('i18n_taxonomy'));
82
    $this->drupalGet('admin/structure/feeds/i18n/settings/FeedsTermProcessor');
83
    $this->assertNoField('language', 'Language field is not available on the term processor settings when the i18n_taxonomy module is disabled.');
84
  }
85

    
86
  /**
87
   * Tests if terms get imported in LANGUAGE_NONE when the i18n_taxonomy module gets disabled.
88
   */
89
  public function testDisabledi18nTaxonomyModule() {
90
    module_disable(array('i18n_taxonomy'));
91
    // Make sure that entity info is reset.
92
    drupal_flush_all_caches();
93
    drupal_static_reset();
94

    
95
    // Import content.
96
    $this->importFile('i18n', $this->absolutePath() . '/tests/feeds/content.csv');
97

    
98
    // Assert that the terms have no language assigned.
99
    $entities = entity_load($this->entityType, array(1, 2));
100
    foreach ($entities as $entity) {
101
      // Terms shouldn't have a language property.
102
      $this->assertFalse(isset($entity->language), 'The term does not have a language.');
103
    }
104
  }
105

    
106
  /**
107
   * Tests if terms get imported in LANGUAGE_NONE when the i18n_taxonomy module gets uninstalled.
108
   */
109
  public function testUninstalledi18nTaxonomyModule() {
110
    module_disable(array('i18n_taxonomy'));
111
    drupal_uninstall_modules(array('i18n_taxonomy'));
112
    // Make sure that entity info is reset.
113
    drupal_flush_all_caches();
114
    drupal_static_reset();
115

    
116
    // Import content.
117
    $this->importFile('i18n', $this->absolutePath() . '/tests/feeds/content.csv');
118

    
119
    // Assert that the terms have no language assigned.
120
    $entities = entity_load($this->entityType, array(1, 2));
121
    foreach ($entities as $entity) {
122
      $this->assertFalse(isset($entity->language), 'The term does not have a language.');
123
    }
124
  }
125

    
126
}