1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Confirm path aliases are saved internally as the system path.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Confirm path aliases are saved internally as the system path.
|
10
|
*/
|
11
|
class LinkConvertInternalPathsTest extends LinkBaseTestClass {
|
12
|
|
13
|
/**
|
14
|
* Description of the tests.
|
15
|
*/
|
16
|
public static function getInfo() {
|
17
|
return array(
|
18
|
'name' => 'Conversion of internal path aliases',
|
19
|
'description' => 'Test that internal path aliases are saved as system paths.',
|
20
|
'group' => 'Link',
|
21
|
);
|
22
|
}
|
23
|
|
24
|
/**
|
25
|
* {@inheritdoc}
|
26
|
*/
|
27
|
public function setUp(array $modules = array()) {
|
28
|
$modules[] = 'path';
|
29
|
parent::setUp($modules);
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* Test the alias handling.
|
34
|
*/
|
35
|
public function testInternalPathConversion() {
|
36
|
// Create 2 fields, one which converts aliases and one which doesn't.
|
37
|
$settings = array(
|
38
|
'instance[settings][convert_aliases]' => TRUE,
|
39
|
);
|
40
|
$field_name_converts = $this->createLinkField('page', $settings);
|
41
|
$field_name_plain = $this->createLinkField('page');
|
42
|
|
43
|
// Programatically create a node with an alias to link to.
|
44
|
$aliased_node = (object) array(
|
45
|
'type' => 'page',
|
46
|
'uid' => 1,
|
47
|
'title' => $this->randomName(),
|
48
|
'path' => array(
|
49
|
'alias' => $this->randomName(),
|
50
|
),
|
51
|
// This is needed for path alias to be saved.
|
52
|
'language' => LANGUAGE_NONE,
|
53
|
);
|
54
|
node_save($aliased_node);
|
55
|
|
56
|
$this->drupalGet($aliased_node->path['alias']);
|
57
|
$this->assertText($aliased_node->title, 'Aliased node created.');
|
58
|
|
59
|
$this->drupalGet('node/add/page');
|
60
|
|
61
|
$label = $this->randomName();
|
62
|
$edit = array(
|
63
|
'title' => $label,
|
64
|
$field_name_converts . '[und][0][title]' => $label,
|
65
|
$field_name_converts . '[und][0][url]' => $aliased_node->path['alias'],
|
66
|
$field_name_plain . '[und][0][title]' => $label,
|
67
|
$field_name_plain . '[und][0][url]' => $aliased_node->path['alias'],
|
68
|
);
|
69
|
$this->drupalPost(NULL, $edit, t('Save'));
|
70
|
$this->assertRaw(' has been created.', 'Node created');
|
71
|
|
72
|
// Load the node that was created.
|
73
|
$url = $this->getUrl();
|
74
|
$split = explode('/', $url);
|
75
|
$nid = array_pop($split);
|
76
|
|
77
|
$node = node_load($nid);
|
78
|
|
79
|
$link_field_converts_items = field_get_items('node', $node, $field_name_converts);
|
80
|
$this->assertEqual($link_field_converts_items[0]['url'], "node/{$aliased_node->nid}", "The field value was saved as the internal path for the alias.");
|
81
|
|
82
|
$link_field_plain_items = field_get_items('node', $node, $field_name_plain);
|
83
|
$this->assertEqual($link_field_plain_items[0]['url'], $aliased_node->path['alias'], "The field value was saved as the given alias.");
|
84
|
}
|
85
|
|
86
|
}
|