Projet

Général

Profil

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

root / drupal7 / sites / all / modules / link / tests / link.attribute.test @ 8e7483ab

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