Projet

Général

Profil

Paste
Télécharger (19,4 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / link / tests / LinkFieldAttributesTest.test @ bad4e148

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5 bad4e148 Assos Assos
 * Field attributes test.
6 85ad3d82 Assos Assos
 */
7
8 39a181a4 Assos Assos
/**
9 bad4e148 Assos Assos
 * Field attributes test.
10 39a181a4 Assos Assos
 */
11 bad4e148 Assos Assos
class LinkFieldAttributesTest extends LinkBaseTestClass {
12 39a181a4 Assos Assos
13 bad4e148 Assos Assos
  /**
14
   * Track a zebra value, used to alternate the output.
15
   *
16
   * @var int
17
   */
18 85ad3d82 Assos Assos
  private $zebra;
19
20 39a181a4 Assos Assos
  /**
21
   * Get Info.
22
   */
23 85ad3d82 Assos Assos
  public static function getInfo() {
24
    return array(
25 bad4e148 Assos Assos
      'name' => 'Link field attribute Tests',
26 85ad3d82 Assos Assos
      'description' => 'Tests the field attributes, making sure they appear in various displayed situations.',
27
      'group' => 'Link',
28
    );
29
  }
30
31 39a181a4 Assos Assos
  /**
32 8e7483ab Assos Assos
   * {@inheritdoc}
33 39a181a4 Assos Assos
   */
34 8e7483ab Assos Assos
  public function setUp(array $modules = array()) {
35
    parent::setUp($modules);
36
37 85ad3d82 Assos Assos
    $this->zebra = 0;
38
  }
39
40 39a181a4 Assos Assos
  /**
41
   * Create Link.
42
   */
43 85ad3d82 Assos Assos
  protected function createLink($url, $title, $attributes = array()) {
44
    return array(
45
      'url' => $url,
46
      'title' => $title,
47
      'attributes' => $attributes,
48
    );
49
  }
50
51 39a181a4 Assos Assos
  /**
52
   * Assert Link On Node.
53
   */
54 85ad3d82 Assos Assos
  protected function assertLinkOnNode($field_name, $link_value, $message = '', $group = 'Other') {
55
    $this->zebra++;
56
    $zebra_string = ($this->zebra % 2 == 0) ? 'even' : 'odd';
57 c8740e19 Assos Assos
    $cssFieldLocator = 'field-' . str_replace('_', '-', $field_name);
58
    $this->assertPattern('@<div class="field field-type-link ' . $cssFieldLocator . '".*<div class="field-item ' . $zebra_string . '">\s*' . $link_value . '\s*</div>@is',
59 39a181a4 Assos Assos
      $message,
60
      $group);
61 85ad3d82 Assos Assos
  }
62
63
  /**
64 39a181a4 Assos Assos
   * Test Basic.
65
   *
66
   * A simple test that just creates a new node type, adds a link field to it,
67
   * creates a new node of that type, and makes sure that the node is being
68
   * displayed.
69 85ad3d82 Assos Assos
   */
70 39a181a4 Assos Assos
  public function testBasic() {
71 85ad3d82 Assos Assos
    $content_type_friendly = $this->randomName(20);
72
    $content_type_machine = strtolower($this->randomName(10));
73
    $title = $this->randomName(20);
74
75
    $this->drupalGet('admin/structure/types');
76
77
    // Create the content type.
78
    $this->clickLink(t('Add content type'));
79
80 c8740e19 Assos Assos
    $edit = array(
81 85ad3d82 Assos Assos
      'name' => $content_type_friendly,
82
      'type' => $content_type_machine,
83
    );
84
    $this->drupalPost(NULL, $edit, t('Save and add fields'));
85
    $this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
86
87
    // Now add a singleton field.
88
    $single_field_name_friendly = $this->randomName(20);
89
    $single_field_name_machine = strtolower($this->randomName(10));
90 39a181a4 Assos Assos
91 c8740e19 Assos Assos
    $edit = array(
92 85ad3d82 Assos Assos
      'fields[_add_new_field][label]' => $single_field_name_friendly,
93
      'fields[_add_new_field][field_name]' => $single_field_name_machine,
94
      'fields[_add_new_field][type]' => 'link_field',
95
      'fields[_add_new_field][widget_type]' => 'link_field',
96
97
    );
98
    $this->drupalPost(NULL, $edit, t('Save'));
99
100
    // We'll go with the default settings for this run-through.
101
    $this->drupalPost(NULL, array(), t('Save field settings'));
102
103
    // Using all the default settings, so press the button.
104
    $this->drupalPost(NULL, array(), t('Save settings'));
105
    $this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
106
107
    // Somehow clicking "save" isn't enough, and we have to do a
108
    // node_types_rebuild().
109
    node_types_rebuild();
110
    menu_rebuild();
111
    $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
112
    $this->assertTrue($type_exists, 'The new content type has been created in the database.');
113
114
    $permission = 'create ' . $content_type_machine . ' content';
115 39a181a4 Assos Assos
116 85ad3d82 Assos Assos
    // Reset the permissions cache.
117
    $this->checkPermissions(array($permission), TRUE);
118
119
    // Now that we have a new content type, create a user that has privileges
120
    // on the content type.
121
    $permissions = array_merge($this->permissions, array($permission));
122
    $this->web_user = $this->drupalCreateUser($permissions);
123
    $this->drupalLogin($this->web_user);
124
125
    // Go to page.
126 c8740e19 Assos Assos
    $this->drupalGet('node/add/' . $content_type_machine);
127 85ad3d82 Assos Assos
128
    // Add a node.
129
    $edit = array(
130
      'title' => $title,
131 c8740e19 Assos Assos
      'field_' . $single_field_name_machine . '[und][0][title]' => 'Link',
132
      'field_' . $single_field_name_machine . '[und][0][url]' => 'http://www.drupal.org/',
133 85ad3d82 Assos Assos
    );
134
135
    $this->drupalPost(NULL, $edit, t('Save'));
136 39a181a4 Assos Assos
    $this->assertText(t('@content_type_friendly @title has been created', array(
137
      '@content_type_friendly' => $content_type_friendly,
138
      '@title' => $title,
139
    )));
140 85ad3d82 Assos Assos
141 c8740e19 Assos Assos
    $this->drupalGet('node/add/' . $content_type_machine);
142 85ad3d82 Assos Assos
143
    // Create a node:
144
    $edit = array(
145
      'title' => $title,
146
      'field_' . $single_field_name_machine . '[und][0][url]' => 'http://www.example.com/',
147
      'field_' . $single_field_name_machine . '[und][0][title]' => 'Display',
148
    );
149
150
    // Now we can fill in the second item in the multivalue field and save.
151
    $this->drupalPost(NULL, $edit, t('Save'));
152 39a181a4 Assos Assos
    $this->assertText(t('@content_type_friendly @title has been created', array(
153
      '@content_type_friendly' => $content_type_friendly,
154
      '@title' => $title,
155
    )));
156 85ad3d82 Assos Assos
157
    $this->assertText('Display');
158
    $this->assertLinkByHref('http://www.example.com');
159
  }
160
161 39a181a4 Assos Assos
  /**
162
   * Create Simple Link Field.
163
   */
164 85ad3d82 Assos Assos
  protected function createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine) {
165
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/fields');
166 c8740e19 Assos Assos
    $edit = array(
167 85ad3d82 Assos Assos
      'fields[_add_new_field][label]' => $single_field_name_friendly,
168
      'fields[_add_new_field][field_name]' => $single_field_name_machine,
169
      'fields[_add_new_field][type]' => 'link_field',
170
      'fields[_add_new_field][widget_type]' => 'link_field',
171
    );
172
    $this->drupalPost(NULL, $edit, t('Save'));
173
174
    // We'll go with the default settings for this run-through.
175
    $this->drupalPost(NULL, array(), t('Save field settings'));
176
177
    // Using all the default settings, so press the button.
178
    $this->drupalPost(NULL, array(), t('Save settings'));
179
    $this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
180
181
    // Somehow clicking "save" isn't enough, and we have to do a
182
    // node_types_rebuild().
183
    node_types_rebuild();
184
    menu_rebuild();
185
    $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
186
    $this->assertTrue($type_exists, 'The new content type has been created in the database.');
187
  }
188
189 39a181a4 Assos Assos
  /**
190
   * Create Node Type User.
191
   */
192 85ad3d82 Assos Assos
  protected function createNodeTypeUser($content_type_machine) {
193
    $permission = 'create ' . $content_type_machine . ' content';
194
    // Reset the permissions cache.
195
    $this->checkPermissions(array($permission), TRUE);
196
197
    // Now that we have a new content type, create a user that has privileges
198
    // on the content type.
199
    $permissions = array_merge($this->permissions, array($permission));
200
    $this->web_user = $this->drupalCreateUser($permissions);
201
    $this->drupalLogin($this->web_user);
202
  }
203
204 39a181a4 Assos Assos
  /**
205
   * Create Node For Testing.
206
   */
207 85ad3d82 Assos Assos
  protected function createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $title, $url, $node_title = '') {
208 c8740e19 Assos Assos
    $this->drupalGet('node/add/' . $content_type_machine);
209 85ad3d82 Assos Assos
210
    if (!$node_title) {
211
      $node_title = $this->randomName(20);
212
    }
213
    $edit = array(
214
      'title' => $node_title,
215
    );
216
    if ($url) {
217
      $edit['field_' . $single_field_name_machine . '[und][0][url]'] = $url;
218
    }
219
    if ($title) {
220
      $edit['field_' . $single_field_name_machine . '[und][0][title]'] = $title;
221
    }
222
223
    $this->drupalPost(NULL, $edit, t('Save'));
224 39a181a4 Assos Assos
    $this->assertText(t('@content_type_friendly @title has been created', array(
225
      '@content_type_friendly' => $content_type_friendly,
226
      '@title' => $node_title,
227
    )));
228 85ad3d82 Assos Assos
  }
229
230
  /**
231
   * Test the link_plain formatter and it's output.
232
   */
233 39a181a4 Assos Assos
  public function testFormatterPlain() {
234 85ad3d82 Assos Assos
    $content_type_friendly = $this->randomName(20);
235
    $content_type_machine = strtolower($this->randomName(10));
236
237
    $this->drupalCreateContentType(array(
238
      'type' => $content_type_machine,
239
      'name' => $content_type_friendly,
240
    ));
241
242
    // Now add a singleton field.
243
    $single_field_name_friendly = $this->randomName(20);
244
    $single_field_name_machine = strtolower($this->randomName(10));
245 39a181a4 Assos Assos
    // $single_field_name = 'field_'. $single_field_name_machine;.
246 85ad3d82 Assos Assos
    $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
247
248
    // Okay, now we want to make sure this display is changed:
249 c8740e19 Assos Assos
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
250 85ad3d82 Assos Assos
    $edit = array(
251 c8740e19 Assos Assos
      'fields[field_' . $single_field_name_machine . '][label]' => 'above',
252
      'fields[field_' . $single_field_name_machine . '][type]' => 'link_plain',
253 85ad3d82 Assos Assos
    );
254
    $this->drupalPost(NULL, $edit, t('Save'));
255
256
    $this->createNodeTypeUser($content_type_machine);
257 39a181a4 Assos Assos
258 85ad3d82 Assos Assos
    $link_tests = array(
259
      'plain' => array(
260
        'text' => 'Display',
261
        'url' => 'http://www.example.com/',
262
      ),
263
      'query' => array(
264
        'text' => 'Display',
265
        'url' => 'http://www.example.com/?q=test',
266
      ),
267
      'fragment' => array(
268
        'text' => 'Display',
269
        'url' => 'http://www.example.com/#test',
270
      ),
271
    );
272
273 39a181a4 Assos Assos
    foreach ($link_tests as $link_test) {
274 85ad3d82 Assos Assos
      $link_text = $link_test['text'];
275
      $link_url = $link_test['url'];
276
      $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
277 39a181a4 Assos Assos
278 85ad3d82 Assos Assos
      $this->assertText($link_url);
279
      $this->assertNoText($link_text);
280
      $this->assertNoLinkByHref($link_url);
281
    }
282
  }
283
284 39a181a4 Assos Assos
  /**
285
   * Formatter Host.
286
   */
287
  public function testFormatterHost() {
288 7fe061e8 Assos Assos
    $content_type_friendly = $this->randomName(20);
289
    $content_type_machine = strtolower($this->randomName(10));
290
291
    $this->drupalCreateContentType(array(
292
      'type' => $content_type_machine,
293
      'name' => $content_type_friendly,
294
    ));
295
296
    // Now add a singleton field.
297
    $single_field_name_friendly = $this->randomName(20);
298
    $single_field_name_machine = strtolower($this->randomName(10));
299 39a181a4 Assos Assos
    // $single_field_name = 'field_'. $single_field_name_machine;.
300 7fe061e8 Assos Assos
    $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
301
302
    // Okay, now we want to make sure this display is changed:
303 39a181a4 Assos Assos
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
304 7fe061e8 Assos Assos
    $edit = array(
305 39a181a4 Assos Assos
      'fields[field_' . $single_field_name_machine . '][label]' => 'above',
306
      'fields[field_' . $single_field_name_machine . '][type]' => 'link_host',
307 7fe061e8 Assos Assos
    );
308
    $this->drupalPost(NULL, $edit, t('Save'));
309
310
    $this->createNodeTypeUser($content_type_machine);
311
312
    $link_text = 'Display';
313
    $link_url = 'http://www.example.com/';
314
    $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
315
316
    $this->assertText('www.example.com');
317
    $this->assertNoText($link_text);
318
    $this->assertNoLinkByHref($link_url);
319
  }
320
321 39a181a4 Assos Assos
  /**
322
   * Formatter URL.
323
   */
324 8e7483ab Assos Assos
  public function testFormatterUrl() {
325 85ad3d82 Assos Assos
    $content_type_friendly = $this->randomName(20);
326
    $content_type_machine = strtolower($this->randomName(10));
327
328
    $this->drupalCreateContentType(array(
329
      'type' => $content_type_machine,
330
      'name' => $content_type_friendly,
331
    ));
332
333
    // Now add a singleton field.
334
    $single_field_name_friendly = $this->randomName(20);
335
    $single_field_name_machine = strtolower($this->randomName(10));
336 39a181a4 Assos Assos
    // $single_field_name = 'field_'. $single_field_name_machine;.
337 85ad3d82 Assos Assos
    $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
338
339
    // Okay, now we want to make sure this display is changed:
340 c8740e19 Assos Assos
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
341 85ad3d82 Assos Assos
    $edit = array(
342 c8740e19 Assos Assos
      'fields[field_' . $single_field_name_machine . '][label]' => 'above',
343
      'fields[field_' . $single_field_name_machine . '][type]' => 'link_url',
344 85ad3d82 Assos Assos
    );
345
    $this->drupalPost(NULL, $edit, t('Save'));
346
347
    $this->createNodeTypeUser($content_type_machine);
348 39a181a4 Assos Assos
349 85ad3d82 Assos Assos
    $link_tests = array(
350
      'plain' => array(
351
        'text' => 'Display',
352
        'url' => 'http://www.example.com/',
353
      ),
354
      'query' => array(
355
        'text' => 'Display',
356
        'url' => 'http://www.example.com/?q=test',
357
      ),
358
      'fragment' => array(
359
        'text' => 'Display',
360
        'url' => 'http://www.example.com/#test',
361
      ),
362
    );
363
364 39a181a4 Assos Assos
    foreach ($link_tests as $link_test) {
365 85ad3d82 Assos Assos
      $link_text = $link_test['text'];
366
      $link_url = $link_test['url'];
367
      $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
368 39a181a4 Assos Assos
369 85ad3d82 Assos Assos
      $this->assertNoText($link_text);
370
      $this->assertLinkByHref($link_url);
371
    }
372
  }
373
374 39a181a4 Assos Assos
  /**
375
   * Formatter Short.
376
   */
377
  public function testFormatterShort() {
378 85ad3d82 Assos Assos
    $content_type_friendly = $this->randomName(20);
379
    $content_type_machine = strtolower($this->randomName(10));
380
381
    $this->drupalCreateContentType(array(
382
      'type' => $content_type_machine,
383
      'name' => $content_type_friendly,
384
    ));
385
386
    // Now add a singleton field.
387
    $single_field_name_friendly = $this->randomName(20);
388
    $single_field_name_machine = strtolower($this->randomName(10));
389 39a181a4 Assos Assos
    // $single_field_name = 'field_'. $single_field_name_machine;.
390 85ad3d82 Assos Assos
    $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
391
392
    // Okay, now we want to make sure this display is changed:
393 c8740e19 Assos Assos
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
394 85ad3d82 Assos Assos
    $edit = array(
395 c8740e19 Assos Assos
      'fields[field_' . $single_field_name_machine . '][label]' => 'above',
396
      'fields[field_' . $single_field_name_machine . '][type]' => 'link_short',
397 85ad3d82 Assos Assos
    );
398
    $this->drupalPost(NULL, $edit, t('Save'));
399
400
    $this->createNodeTypeUser($content_type_machine);
401
402
    $link_tests = array(
403
      'plain' => array(
404
        'text' => 'Display',
405
        'url' => 'http://www.example.com/',
406
      ),
407
      'query' => array(
408
        'text' => 'Display',
409
        'url' => 'http://www.example.com/?q=test',
410
      ),
411
      'fragment' => array(
412
        'text' => 'Display',
413
        'url' => 'http://www.example.com/#test',
414
      ),
415
    );
416
417 39a181a4 Assos Assos
    foreach ($link_tests as $link_test) {
418 85ad3d82 Assos Assos
      $link_text = $link_test['text'];
419
      $link_url = $link_test['url'];
420
      $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
421 39a181a4 Assos Assos
422 85ad3d82 Assos Assos
      $this->assertText('Link');
423
      $this->assertNoText($link_text);
424
      $this->assertLinkByHref($link_url);
425
    }
426
  }
427
428 39a181a4 Assos Assos
  /**
429
   * Formatter Label.
430
   */
431
  public function testFormatterLabel() {
432 85ad3d82 Assos Assos
    $content_type_friendly = $this->randomName(20);
433
    $content_type_machine = strtolower($this->randomName(10));
434
435
    $this->drupalCreateContentType(array(
436
      'type' => $content_type_machine,
437
      'name' => $content_type_friendly,
438
    ));
439
440
    // Now add a singleton field.
441
    $single_field_name_friendly = $this->randomName(20);
442
    $single_field_name_machine = strtolower($this->randomName(10));
443 39a181a4 Assos Assos
    // $single_field_name = 'field_'. $single_field_name_machine;.
444 85ad3d82 Assos Assos
    $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
445
446
    // Okay, now we want to make sure this display is changed:
447 c8740e19 Assos Assos
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
448 85ad3d82 Assos Assos
    $edit = array(
449 c8740e19 Assos Assos
      'fields[field_' . $single_field_name_machine . '][label]' => 'above',
450
      'fields[field_' . $single_field_name_machine . '][type]' => 'link_label',
451 85ad3d82 Assos Assos
    );
452
    $this->drupalPost(NULL, $edit, t('Save'));
453
454
    $this->createNodeTypeUser($content_type_machine);
455
456
    $link_tests = array(
457
      'plain' => array(
458
        'text' => 'Display',
459
        'url' => 'http://www.example.com/',
460
      ),
461
      'query' => array(
462
        'text' => 'Display',
463
        'url' => 'http://www.example.com/?q=test',
464
      ),
465
      'fragment' => array(
466
        'text' => 'Display',
467
        'url' => 'http://www.example.com/#test',
468
      ),
469
    );
470
471 39a181a4 Assos Assos
    foreach ($link_tests as $link_test) {
472 85ad3d82 Assos Assos
      $link_text = $link_test['text'];
473 39a181a4 Assos Assos
      $link_url = $link_test['url'];
474 85ad3d82 Assos Assos
      $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
475 39a181a4 Assos Assos
476 85ad3d82 Assos Assos
      $this->assertNoText($link_text);
477
      $this->assertText($single_field_name_friendly);
478
      $this->assertLinkByHref($link_url);
479
    }
480
  }
481
482 39a181a4 Assos Assos
  /**
483
   * Formatter Separate.
484
   */
485
  public function testFormatterSeparate() {
486 85ad3d82 Assos Assos
    $content_type_friendly = $this->randomName(20);
487
    $content_type_machine = strtolower($this->randomName(10));
488
489
    $this->drupalCreateContentType(array(
490
      'type' => $content_type_machine,
491
      'name' => $content_type_friendly,
492
    ));
493
494
    // Now add a singleton field.
495
    $single_field_name_friendly = $this->randomName(20);
496
    $single_field_name_machine = strtolower($this->randomName(10));
497 39a181a4 Assos Assos
    // $single_field_name = 'field_'. $single_field_name_machine;.
498 85ad3d82 Assos Assos
    $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
499
500
    // Okay, now we want to make sure this display is changed:
501 c8740e19 Assos Assos
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
502 85ad3d82 Assos Assos
    $edit = array(
503 c8740e19 Assos Assos
      'fields[field_' . $single_field_name_machine . '][label]' => 'above',
504
      'fields[field_' . $single_field_name_machine . '][type]' => 'link_separate',
505 85ad3d82 Assos Assos
    );
506
    $this->drupalPost(NULL, $edit, t('Save'));
507
508
    $this->createNodeTypeUser($content_type_machine);
509
510
    $plain_url = 'http://www.example.com/';
511
    $link_tests = array(
512
      'plain' => array(
513
        'text' => $this->randomName(20),
514
        'url' => $plain_url,
515
      ),
516
      'query' => array(
517
        'text' => $this->randomName(20),
518
        'url' => $plain_url . '?q=test',
519
      ),
520
      'fragment' => array(
521
        'text' => $this->randomName(20),
522
        'url' => $plain_url . '#test',
523
      ),
524
    );
525
526 39a181a4 Assos Assos
    foreach ($link_tests as $link_test) {
527 85ad3d82 Assos Assos
      $link_text = $link_test['text'];
528
      $link_url = $link_test['url'];
529
      $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
530 39a181a4 Assos Assos
531 85ad3d82 Assos Assos
      $this->assertText($link_text);
532
      $this->assertLink($plain_url);
533
      $this->assertLinkByHref($link_url);
534
    }
535
  }
536 39a181a4 Assos Assos
537
  /**
538
   * Formatter Plain Title.
539
   */
540
  public function testFormatterPlainTitle() {
541 85ad3d82 Assos Assos
    $content_type_friendly = $this->randomName(20);
542
    $content_type_machine = strtolower($this->randomName(10));
543 39a181a4 Assos Assos
544 85ad3d82 Assos Assos
    $this->drupalCreateContentType(array(
545
      'type' => $content_type_machine,
546
      'name' => $content_type_friendly,
547
    ));
548 39a181a4 Assos Assos
549 85ad3d82 Assos Assos
    // Now add a singleton field.
550
    $single_field_name_friendly = $this->randomName(20);
551
    $single_field_name_machine = strtolower($this->randomName(10));
552 39a181a4 Assos Assos
    // $single_field_name = 'field_'. $single_field_name_machine;.
553 85ad3d82 Assos Assos
    $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
554 39a181a4 Assos Assos
555 85ad3d82 Assos Assos
    // Okay, now we want to make sure this display is changed:
556 c8740e19 Assos Assos
    $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
557 85ad3d82 Assos Assos
    $edit = array(
558 c8740e19 Assos Assos
      'fields[field_' . $single_field_name_machine . '][label]' => 'above',
559
      'fields[field_' . $single_field_name_machine . '][type]' => 'link_title_plain',
560 85ad3d82 Assos Assos
    );
561
    $this->drupalPost(NULL, $edit, t('Save'));
562 39a181a4 Assos Assos
563 85ad3d82 Assos Assos
    $this->createNodeTypeUser($content_type_machine);
564 39a181a4 Assos Assos
565 85ad3d82 Assos Assos
    $link_text = 'Display';
566
    $link_url = 'http://www.example.com/';
567
    $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
568 39a181a4 Assos Assos
569 85ad3d82 Assos Assos
    $this->assertText($link_text);
570
    $this->assertNoText($link_url);
571
    $this->assertNoLinkByHref($link_url);
572
  }
573 39a181a4 Assos Assos
574 85ad3d82 Assos Assos
}