1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Test case for multilingual menus.
|
6
|
*/
|
7
|
class i18nPathTestCase extends Drupali18nTestCase {
|
8
|
public static function getInfo() {
|
9
|
return array(
|
10
|
'name' => 'Path translation',
|
11
|
'group' => 'Internationalization',
|
12
|
'description' => 'Path translation functions',
|
13
|
);
|
14
|
}
|
15
|
|
16
|
function setUp() {
|
17
|
parent::setUp('translation', 'i18n_path');
|
18
|
parent::setUpLanguages(array('administer site configuration'));
|
19
|
}
|
20
|
|
21
|
function checkTranslationLink($path, $language, $method = 'assertRaw') {
|
22
|
$this->{$method}($path, t('Found translation link. :language - :path', array(':language' => $language, ':path' => $path)));
|
23
|
}
|
24
|
|
25
|
function testPathTranslation() {
|
26
|
$this->setUpContentType(array('type' => 'page', 'mode' => TRANSLATION_ENABLED));
|
27
|
|
28
|
// Create 2 nodes in different languages.
|
29
|
$first_title = $this->randomName(10);
|
30
|
$first_body = $this->randomString(50);
|
31
|
$first_node = $this->createNode('page', $first_title, $first_body, $this->default_language);
|
32
|
|
33
|
$secondary_title = $this->randomName(10);
|
34
|
$secondary_body = $this->randomString(50);
|
35
|
$secondary_node = $this->createNode('page', $secondary_title, $secondary_body, $this->secondary_language);
|
36
|
|
37
|
$this->drupalGet('node/' . $first_node->nid);
|
38
|
$this->checkTranslationLink('node/' . $first_node->nid, $first_node->language);
|
39
|
$this->checkTranslationLink($this->secondary_language . '/node/' . $first_node->nid, $this->secondary_language, 'assertNoRaw');
|
40
|
|
41
|
$this->drupalGet('node/' . $secondary_node->nid);
|
42
|
$this->checkTranslationLink('node/' . $secondary_node->nid, $secondary_node->language);
|
43
|
$this->checkTranslationLink($this->secondary_language . '/node/' . $secondary_node->nid, $this->secondary_language);
|
44
|
|
45
|
$this->drupalGet('admin/config/regional/i18n_translation/path');
|
46
|
$this->clickLink(t('Add path translation'));
|
47
|
|
48
|
// create new translation set with two node links
|
49
|
$edit = array(
|
50
|
'title' => $this->randomName(10),
|
51
|
'translations[' . $this->default_language . ']' => 'node/' . $first_node->nid,
|
52
|
'translations[' . $this->secondary_language . ']' => 'node/' . $secondary_node->nid,
|
53
|
);
|
54
|
$this->drupalPost('admin/config/regional/i18n_translation/path/add', $edit, t('Save'));
|
55
|
|
56
|
$this->drupalGet('node/' . $first_node->nid);
|
57
|
$this->checkTranslationLink('node/' . $first_node->nid, $first_node->language);
|
58
|
$this->checkTranslationLink($this->secondary_language . '/node/' . $secondary_node->nid, $this->secondary_language);
|
59
|
|
60
|
$this->drupalGet('node/' . $secondary_node->nid);
|
61
|
$this->checkTranslationLink('node/' . $first_node->nid, $first_node->language);
|
62
|
$this->checkTranslationLink('node/' . $secondary_node->nid, $this->secondary_language);
|
63
|
|
64
|
// create new translation set with one node and one menu "token"
|
65
|
$edit = array(
|
66
|
'translations[' . $this->default_language . ']' => 'node/' . $first_node->nid,
|
67
|
'translations[' . $this->secondary_language . ']' => '<front>',
|
68
|
);
|
69
|
$this->drupalPost('admin/config/regional/i18n_translation/path/edit/1', $edit, t('Save'));
|
70
|
|
71
|
$this->drupalGet('node/' . $first_node->nid);
|
72
|
$this->checkTranslationLink('node/' . $first_node->nid, $first_node->language);
|
73
|
$this->checkTranslationLink('node/' . $secondary_node->nid, $this->secondary_language, 'assertNoLinkByHref');
|
74
|
$this->checkTranslationLink($this->secondary_language, $this->secondary_language);
|
75
|
|
76
|
// create new translation set with one node and an external menu link.
|
77
|
$url = 'http://' . $this->randomName(10) . '.' . $this->randomName(2);
|
78
|
$edit = array(
|
79
|
'translations[' . $this->default_language . ']' => 'node/' . $first_node->nid,
|
80
|
'translations[' . $this->secondary_language . ']' => $url,
|
81
|
);
|
82
|
$this->drupalPost('admin/config/regional/i18n_translation/path/edit/1', $edit, t('Save'));
|
83
|
|
84
|
$this->drupalGet('node/' . $first_node->nid);
|
85
|
$this->checkTranslationLink('node/' . $first_node->nid, $first_node->language);
|
86
|
$this->checkTranslationLink($url, $this->secondary_language);
|
87
|
}
|
88
|
}
|