1 |
a192dc0b
|
Assos Assos
|
<?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 |
|
|
public static function getInfo() {
|
21 |
|
|
return array(
|
22 |
|
|
'name' => 'Multilingual terms',
|
23 |
|
|
'description' => 'Tests Feeds multilingual support for taxonomy terms.',
|
24 |
|
|
'group' => 'Feeds',
|
25 |
|
|
'dependencies' => array('locale', 'i18n_taxonomy'),
|
26 |
|
|
);
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
public function setUp($modules = array(), $permissions = array()) {
|
30 |
|
|
$this->entityType = 'taxonomy_term';
|
31 |
|
|
$this->processorName = 'FeedsTermProcessor';
|
32 |
|
|
|
33 |
|
|
$modules = array_merge($modules, array(
|
34 |
|
|
'i18n_taxonomy',
|
35 |
|
|
));
|
36 |
|
|
parent::setUp($modules, $permissions);
|
37 |
|
|
|
38 |
|
|
// Create vocabulary.
|
39 |
|
|
$this->vocabulary = strtolower($this->randomName(8));
|
40 |
|
|
$edit = array(
|
41 |
|
|
'name' => $this->vocabulary,
|
42 |
|
|
'machine_name' => $this->vocabulary,
|
43 |
|
|
);
|
44 |
|
|
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
|
45 |
|
|
|
46 |
|
|
// Configure importer.
|
47 |
|
|
$this->setSettings('i18n', $this->processorName, array(
|
48 |
|
|
'bundle' => $this->vocabulary,
|
49 |
|
|
'language' => 'de',
|
50 |
|
|
'update_existing' => FEEDS_UPDATE_EXISTING,
|
51 |
|
|
'skip_hash_check' => TRUE,
|
52 |
|
|
));
|
53 |
|
|
$this->addMappings('i18n', array(
|
54 |
|
|
0 => array(
|
55 |
|
|
'source' => 'guid',
|
56 |
|
|
'target' => 'guid',
|
57 |
|
|
'unique' => '1',
|
58 |
|
|
),
|
59 |
|
|
1 => array(
|
60 |
|
|
'source' => 'title',
|
61 |
|
|
'target' => 'name',
|
62 |
|
|
),
|
63 |
|
|
));
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* Tests if the language setting is available on the processor.
|
68 |
|
|
*/
|
69 |
|
|
public function testAvailableProcessorLanguageSetting() {
|
70 |
|
|
// Check if the language setting is available when the i18n_taxonomy module is enabled.
|
71 |
|
|
$this->drupalGet('admin/structure/feeds/i18n/settings/FeedsTermProcessor');
|
72 |
|
|
$this->assertField('language', 'Language field is available on the term processor settings when the i18n_taxonomy module is enabled.');
|
73 |
|
|
|
74 |
|
|
// Disable the i18n_taxonomy module and check if the language setting is no longer available.
|
75 |
|
|
module_disable(array('i18n_taxonomy'));
|
76 |
|
|
$this->drupalGet('admin/structure/feeds/i18n/settings/FeedsTermProcessor');
|
77 |
|
|
$this->assertNoField('language', 'Language field is not available on the term processor settings when the i18n_taxonomy module is disabled.');
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
/**
|
81 |
|
|
* Tests if terms get imported in LANGUAGE_NONE when the i18n_taxonomy module gets disabled.
|
82 |
|
|
*/
|
83 |
|
|
public function testDisabledi18nTaxonomyModule() {
|
84 |
|
|
module_disable(array('i18n_taxonomy'));
|
85 |
|
|
// Make sure that entity info is reset.
|
86 |
|
|
drupal_flush_all_caches();
|
87 |
|
|
drupal_static_reset();
|
88 |
|
|
|
89 |
|
|
// Import content.
|
90 |
|
|
$this->importFile('i18n', $this->absolutePath() . '/tests/feeds/content.csv');
|
91 |
|
|
|
92 |
|
|
// Assert that the terms have no language assigned.
|
93 |
|
|
$entities = entity_load($this->entityType, array(1, 2));
|
94 |
|
|
foreach ($entities as $entity) {
|
95 |
|
|
// Terms shouldn't have a language property.
|
96 |
|
|
$this->assertFalse(isset($entity->language), 'The term does not have a language.');
|
97 |
|
|
}
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
/**
|
101 |
|
|
* Tests if terms get imported in LANGUAGE_NONE when the i18n_taxonomy module gets uninstalled.
|
102 |
|
|
*/
|
103 |
|
|
public function testUninstalledi18nTaxonomyModule() {
|
104 |
|
|
module_disable(array('i18n_taxonomy'));
|
105 |
|
|
drupal_uninstall_modules(array('i18n_taxonomy'));
|
106 |
|
|
// Make sure that entity info is reset.
|
107 |
|
|
drupal_flush_all_caches();
|
108 |
|
|
drupal_static_reset();
|
109 |
|
|
|
110 |
|
|
// Import content.
|
111 |
|
|
$this->importFile('i18n', $this->absolutePath() . '/tests/feeds/content.csv');
|
112 |
|
|
|
113 |
|
|
// Assert that the terms have no language assigned.
|
114 |
|
|
$entities = entity_load($this->entityType, array(1, 2));
|
115 |
|
|
foreach ($entities as $entity) {
|
116 |
|
|
$this->assertFalse(isset($entity->language), 'The term does not have a language.');
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
} |