Projet

Général

Profil

Paste
Télécharger (1,56 ko) Statistiques
| Branche: | Révision:

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Link base test file - contains common functions for testing links.
6
 */
7

    
8
/**
9
 * Base Test Class.
10
 */
11
class LinkBaseTestClass extends DrupalWebTestCase {
12

    
13
  protected $permissions = array(
14
    'access content',
15
    'administer content types',
16
    'administer fields',
17
    'administer nodes',
18
    'administer filters',
19
    'access comments',
20
    'post comments',
21
    'access administration pages',
22
    'create page content',
23
  );
24

    
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function setUp(array $modules = array()) {
29
    $modules[] = 'field_ui';
30
    $modules[] = 'link';
31
    parent::setUp($modules);
32

    
33
    $this->web_user = $this->drupalCreateUser($this->permissions);
34
    $this->drupalLogin($this->web_user);
35
  }
36

    
37
  /**
38
   * Create Link Field.
39
   */
40
  protected function createLinkField($node_type = 'page', $settings = array()) {
41
    $name = strtolower($this->randomName());
42
    $edit = array(
43
      'fields[_add_new_field][label]' => $name,
44
      'fields[_add_new_field][field_name]' => $name,
45
      'fields[_add_new_field][type]' => 'link_field',
46
      'fields[_add_new_field][widget_type]' => 'link_field',
47
    );
48
    $field_name = 'field_' . $name;
49
    $this->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
50
    $this->drupalPost(NULL, array(), t('Save field settings'));
51
    $this->drupalPost(NULL, $settings, t('Save settings'));
52

    
53
    // Is field created?
54
    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
55
    node_types_rebuild();
56
    menu_rebuild();
57

    
58
    return $field_name;
59
  }
60

    
61
}