annotate openmindattribute/tests/link.attribute.test @ 60:1b520696760a default tip

new ismixml_splitter.py that splits openmind-data.xml into separate files per entity type.
author casties
date Tue, 19 Jun 2018 21:46:49 +0200
parents 124ef8f3b22d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
1 <?php
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
2
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
3 /**
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
4 * @file
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
5 * Basic simpletests to test options on link module.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
6 */
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
7
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
8 class LinkAttributeCrudTest extends DrupalWebTestCase {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
9 private $zebra;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
10
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
11 protected $permissions = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
12 'access content',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
13 'administer content types',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
14 'administer nodes',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
15 'administer filters',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
16 'access comments',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
17 'post comments',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
18 'skip comment approval',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
19 'access administration pages',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
20 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
21
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
22 public static function getInfo() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
23 return array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
24 'name' => 'Link Attribute Tests',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
25 'description' => 'Tests the field attributes, making sure they appear in various displayed situations.',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
26 'group' => 'Link',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
27 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
28 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
29
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
30 function setup() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
31 parent::setup('field_ui', 'link');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
32 $this->zebra = 0;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
33 // Create and login user.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
34 $this->web_user = $this->drupalCreateUser(array('administer content types'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
35 $this->drupalLogin($this->web_user);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
36 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
37
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
38 protected function createLink($url, $title, $attributes = array()) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
39 return array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
40 'url' => $url,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
41 'title' => $title,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
42 'attributes' => $attributes,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
43 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
44 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
45
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
46 protected function assertLinkOnNode($field_name, $link_value, $message = '', $group = 'Other') {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
47 $this->zebra++;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
48 $zebra_string = ($this->zebra % 2 == 0) ? 'even' : 'odd';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
49 $cssFieldLocator = 'field-'. str_replace('_', '-', $field_name);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
50 $this->assertPattern('@<div class="field field-type-link '. $cssFieldLocator .'".*<div class="field-item '. $zebra_string .'">\s*'. $link_value .'\s*</div>@is',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
51 $message,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
52 $group);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
53 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
54
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
55 /**
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
56 * A simple test that just creates a new node type, adds a link field to it, creates a new node of that type, and makes sure
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
57 * that the node is being displayed.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
58 */
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
59 function testBasic() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
60 $content_type_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
61 $content_type_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
62 $title = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
63
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
64 $this->drupalGet('admin/structure/types');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
65
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
66 // Create the content type.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
67 $this->clickLink(t('Add content type'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
68
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
69 $edit = array (
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
70 'name' => $content_type_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
71 'type' => $content_type_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
72 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
73 $this->drupalPost(NULL, $edit, t('Save and add fields'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
74 $this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
75
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
76 // Now add a singleton field.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
77 $single_field_name_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
78 $single_field_name_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
79 $single_field_name = 'field_'. $single_field_name_machine;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
80 $edit = array (
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
81 'fields[_add_new_field][label]' => $single_field_name_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
82 'fields[_add_new_field][field_name]' => $single_field_name_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
83 'fields[_add_new_field][type]' => 'link_field',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
84 'fields[_add_new_field][widget_type]' => 'link_field',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
85
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
86 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
87 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
88
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
89 // We'll go with the default settings for this run-through.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
90 $this->drupalPost(NULL, array(), t('Save field settings'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
91
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
92 // Using all the default settings, so press the button.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
93 $this->drupalPost(NULL, array(), t('Save settings'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
94 $this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
95
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
96 // Somehow clicking "save" isn't enough, and we have to do a
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
97 // node_types_rebuild().
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
98 node_types_rebuild();
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
99 menu_rebuild();
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
100 $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
101 $this->assertTrue($type_exists, 'The new content type has been created in the database.');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
102
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
103 $permission = 'create ' . $content_type_machine . ' content';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
104 $permission_edit = 'edit ' . $content_type_machine . ' content';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
105 // Reset the permissions cache.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
106 $this->checkPermissions(array($permission), TRUE);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
107
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
108 // Now that we have a new content type, create a user that has privileges
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
109 // on the content type.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
110 $permissions = array_merge($this->permissions, array($permission));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
111 $this->web_user = $this->drupalCreateUser($permissions);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
112 $this->drupalLogin($this->web_user);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
113
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
114 // Go to page.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
115 $this->drupalGet('node/add/'. $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
116
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
117 // Add a node.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
118 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
119 'title' => $title,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
120 'field_'. $single_field_name_machine. '[und][0][title]' => 'Link',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
121 'field_'. $single_field_name_machine. '[und][0][url]' => 'http://www.drupal.org/',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
122 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
123
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
124 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
125 $this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
126
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
127 $this->drupalGet('node/add/'. $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
128
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
129 // Create a node:
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
130 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
131 'title' => $title,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
132 'field_' . $single_field_name_machine . '[und][0][url]' => 'http://www.example.com/',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
133 'field_' . $single_field_name_machine . '[und][0][title]' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
134 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
135
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
136 // Now we can fill in the second item in the multivalue field and save.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
137 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
138 $this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
139
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
140 $this->assertText('Display');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
141 $this->assertLinkByHref('http://www.example.com');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
142 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
143
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
144 protected function createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
145 $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/fields');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
146 $edit = array (
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
147 'fields[_add_new_field][label]' => $single_field_name_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
148 'fields[_add_new_field][field_name]' => $single_field_name_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
149 'fields[_add_new_field][type]' => 'link_field',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
150 'fields[_add_new_field][widget_type]' => 'link_field',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
151 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
152 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
153
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
154 // We'll go with the default settings for this run-through.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
155 $this->drupalPost(NULL, array(), t('Save field settings'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
156
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
157 // Using all the default settings, so press the button.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
158 $this->drupalPost(NULL, array(), t('Save settings'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
159 $this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
160
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
161 // Somehow clicking "save" isn't enough, and we have to do a
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
162 // node_types_rebuild().
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
163 node_types_rebuild();
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
164 menu_rebuild();
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
165 $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
166 $this->assertTrue($type_exists, 'The new content type has been created in the database.');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
167 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
168
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
169 protected function createNodeTypeUser($content_type_machine) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
170 $permission = 'create ' . $content_type_machine . ' content';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
171 $permission_edit = 'edit ' . $content_type_machine . ' content';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
172 // Reset the permissions cache.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
173 $this->checkPermissions(array($permission), TRUE);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
174
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
175 // Now that we have a new content type, create a user that has privileges
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
176 // on the content type.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
177 $permissions = array_merge($this->permissions, array($permission));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
178 $this->web_user = $this->drupalCreateUser($permissions);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
179 $this->drupalLogin($this->web_user);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
180 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
181
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
182 protected function createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $title, $url, $node_title = '') {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
183 $this->drupalGet('node/add/'. $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
184
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
185 if (!$node_title) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
186 $node_title = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
187 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
188 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
189 'title' => $node_title,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
190 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
191 if ($url) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
192 $edit['field_' . $single_field_name_machine . '[und][0][url]'] = $url;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
193 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
194 if ($title) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
195 $edit['field_' . $single_field_name_machine . '[und][0][title]'] = $title;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
196 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
197
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
198 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
199 $this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $node_title)));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
200
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
201 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
202
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
203 /**
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
204 * Test the link_plain formatter and it's output.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
205 */
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
206 function testFormatterPlain() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
207 $content_type_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
208 $content_type_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
209
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
210 $this->drupalCreateContentType(array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
211 'type' => $content_type_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
212 'name' => $content_type_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
213 ));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
214
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
215 // Now add a singleton field.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
216 $single_field_name_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
217 $single_field_name_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
218 //$single_field_name = 'field_'. $single_field_name_machine;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
219 $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
220
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
221 // Okay, now we want to make sure this display is changed:
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
222 $this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
223 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
224 'fields[field_'. $single_field_name_machine .'][label]' => 'above',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
225 'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
226 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
227 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
228
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
229 $this->createNodeTypeUser($content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
230
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
231 $link_tests = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
232 'plain' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
233 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
234 'url' => 'http://www.example.com/',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
235 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
236 'query' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
237 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
238 'url' => 'http://www.example.com/?q=test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
239 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
240 'fragment' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
241 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
242 'url' => 'http://www.example.com/#test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
243 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
244 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
245
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
246 foreach ($link_tests as $key => $link_test) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
247 $link_text = $link_test['text'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
248 $link_url = $link_test['url'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
249 $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
250
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
251 $this->assertText($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
252 $this->assertNoText($link_text);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
253 $this->assertNoLinkByHref($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
254 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
255 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
256
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
257 function testFormatterURL() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
258 $content_type_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
259 $content_type_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
260
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
261 $this->drupalCreateContentType(array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
262 'type' => $content_type_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
263 'name' => $content_type_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
264 ));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
265
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
266 // Now add a singleton field.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
267 $single_field_name_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
268 $single_field_name_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
269 //$single_field_name = 'field_'. $single_field_name_machine;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
270 $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
271
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
272 // Okay, now we want to make sure this display is changed:
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
273 $this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
274 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
275 'fields[field_'. $single_field_name_machine .'][label]' => 'above',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
276 'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
277 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
278 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
279
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
280 $this->createNodeTypeUser($content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
281
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
282 $link_tests = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
283 'plain' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
284 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
285 'url' => 'http://www.example.com/',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
286 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
287 'query' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
288 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
289 'url' => 'http://www.example.com/?q=test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
290 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
291 'fragment' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
292 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
293 'url' => 'http://www.example.com/#test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
294 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
295 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
296
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
297 foreach ($link_tests as $key => $link_test) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
298 $link_text = $link_test['text'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
299 $link_url = $link_test['url'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
300 $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
301
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
302 $this->assertNoText($link_text);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
303 $this->assertLinkByHref($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
304 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
305 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
306
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
307 function testFormatterShort() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
308 $content_type_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
309 $content_type_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
310
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
311 $this->drupalCreateContentType(array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
312 'type' => $content_type_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
313 'name' => $content_type_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
314 ));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
315
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
316 // Now add a singleton field.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
317 $single_field_name_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
318 $single_field_name_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
319 //$single_field_name = 'field_'. $single_field_name_machine;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
320 $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
321
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
322 // Okay, now we want to make sure this display is changed:
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
323 $this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
324 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
325 'fields[field_'. $single_field_name_machine .'][label]' => 'above',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
326 'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
327 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
328 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
329
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
330 $this->createNodeTypeUser($content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
331
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
332 $link_tests = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
333 'plain' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
334 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
335 'url' => 'http://www.example.com/',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
336 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
337 'query' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
338 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
339 'url' => 'http://www.example.com/?q=test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
340 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
341 'fragment' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
342 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
343 'url' => 'http://www.example.com/#test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
344 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
345 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
346
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
347 foreach ($link_tests as $key => $link_test) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
348 $link_text = $link_test['text'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
349 $link_url = $link_test['url'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
350 $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
351
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
352 $this->assertText('Link');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
353 $this->assertNoText($link_text);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
354 $this->assertLinkByHref($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
355 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
356 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
357
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
358 function testFormatterLabel() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
359 $content_type_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
360 $content_type_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
361
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
362 $this->drupalCreateContentType(array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
363 'type' => $content_type_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
364 'name' => $content_type_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
365 ));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
366
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
367 // Now add a singleton field.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
368 $single_field_name_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
369 $single_field_name_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
370 //$single_field_name = 'field_'. $single_field_name_machine;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
371 $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
372
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
373 // Okay, now we want to make sure this display is changed:
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
374 $this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
375 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
376 'fields[field_'. $single_field_name_machine .'][label]' => 'above',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
377 'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
378 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
379 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
380
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
381 $this->createNodeTypeUser($content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
382
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
383 $link_tests = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
384 'plain' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
385 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
386 'url' => 'http://www.example.com/',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
387 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
388 'query' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
389 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
390 'url' => 'http://www.example.com/?q=test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
391 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
392 'fragment' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
393 'text' => 'Display',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
394 'url' => 'http://www.example.com/#test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
395 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
396 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
397
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
398 foreach ($link_tests as $key => $link_test) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
399 $link_text = $link_test['text'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
400 $link_url = $link_test['url'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
401 $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
402
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
403 $this->assertNoText($link_text);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
404 $this->assertText($single_field_name_friendly);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
405 $this->assertLinkByHref($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
406 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
407 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
408
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
409 function testFormatterSeparate() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
410 $content_type_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
411 $content_type_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
412
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
413 $this->drupalCreateContentType(array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
414 'type' => $content_type_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
415 'name' => $content_type_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
416 ));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
417
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
418 // Now add a singleton field.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
419 $single_field_name_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
420 $single_field_name_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
421 //$single_field_name = 'field_'. $single_field_name_machine;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
422 $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
423
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
424 // Okay, now we want to make sure this display is changed:
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
425 $this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
426 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
427 'fields[field_'. $single_field_name_machine .'][label]' => 'above',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
428 'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
429 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
430 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
431
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
432 $this->createNodeTypeUser($content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
433
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
434 $plain_url = 'http://www.example.com/';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
435 $link_tests = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
436 'plain' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
437 'text' => $this->randomName(20),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
438 'url' => $plain_url,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
439 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
440 'query' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
441 'text' => $this->randomName(20),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
442 'url' => $plain_url . '?q=test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
443 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
444 'fragment' => array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
445 'text' => $this->randomName(20),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
446 'url' => $plain_url . '#test',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
447 ),
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
448 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
449
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
450 foreach ($link_tests as $key => $link_test) {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
451 $link_text = $link_test['text'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
452 $link_url = $link_test['url'];
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
453 $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
454
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
455 $this->assertText($link_text);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
456 $this->assertLink($plain_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
457 $this->assertLinkByHref($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
458 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
459 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
460
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
461 function testFormatterPlainTitle() {
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
462 $content_type_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
463 $content_type_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
464
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
465 $this->drupalCreateContentType(array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
466 'type' => $content_type_machine,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
467 'name' => $content_type_friendly,
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
468 ));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
469
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
470 // Now add a singleton field.
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
471 $single_field_name_friendly = $this->randomName(20);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
472 $single_field_name_machine = strtolower($this->randomName(10));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
473 //$single_field_name = 'field_'. $single_field_name_machine;
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
474 $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
475
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
476 // Okay, now we want to make sure this display is changed:
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
477 $this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
478 $edit = array(
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
479 'fields[field_'. $single_field_name_machine .'][label]' => 'above',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
480 'fields[field_'. $single_field_name_machine .'][type]' => 'link_title_plain',
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
481 );
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
482 $this->drupalPost(NULL, $edit, t('Save'));
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
483
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
484 $this->createNodeTypeUser($content_type_machine);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
485
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
486 $link_text = 'Display';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
487 $link_url = 'http://www.example.com/';
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
488 $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
489
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
490 $this->assertText($link_text);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
491 $this->assertNoText($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
492 $this->assertNoLinkByHref($link_url);
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
493 }
124ef8f3b22d initial
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
diff changeset
494 }