Projet

Général

Profil

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

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Base test class with helper methods, etc.
6
 */
7

    
8
/**
9
 * Base test class with helper methods, etc.
10
 */
11
class LinkBaseTestClass extends DrupalWebTestCase {
12

    
13
  /**
14
   * Default permissions used on tests.
15
   *
16
   * @var array
17
   */
18
  protected $permissions = array(
19
    'access content',
20
    'administer content types',
21
    'administer fields',
22
    'administer nodes',
23
    'administer filters',
24
    'access comments',
25
    'post comments',
26
    'access administration pages',
27
    'create page content',
28
  );
29

    
30
  /**
31
   * {@inheritdoc}
32
   */
33
  public function setUp(array $modules = array()) {
34
    // Most of the tests require the field UI to create & modify fields.
35
    $modules[] = 'field_ui';
36

    
37
    // This module.
38
    $modules[] = 'link';
39

    
40
    parent::setUp($modules);
41

    
42
    $this->web_user = $this->drupalCreateUser($this->permissions);
43
    $this->drupalLogin($this->web_user);
44
  }
45

    
46
  /**
47
   * Create Link Field.
48
   */
49
  protected function createLinkField($node_type = 'page', $settings = array()) {
50
    $name = strtolower($this->randomName());
51
    $edit = array(
52
      'fields[_add_new_field][label]' => $name,
53
      'fields[_add_new_field][field_name]' => $name,
54
      'fields[_add_new_field][type]' => 'link_field',
55
      'fields[_add_new_field][widget_type]' => 'link_field',
56
    );
57
    $field_name = 'field_' . $name;
58
    $this->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
59
    $this->drupalPost(NULL, array(), t('Save field settings'));
60
    $this->drupalPost(NULL, $settings, t('Save settings'));
61

    
62
    // Is field created?
63
    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
64
    node_types_rebuild();
65
    menu_rebuild();
66

    
67
    return $field_name;
68
  }
69

    
70
}