Projet

Général

Profil

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

root / drupal7 / sites / all / modules / link / tests / link.test @ 39a181a4

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
   * Setup.
27
   */
28
  public function setUp() {
29
    $modules = func_get_args();
30
    $modules = (isset($modules[0]) && is_array($modules[0]) ? $modules[0] : $modules);
31
    $modules[] = 'field_ui';
32
    $modules[] = 'link';
33
    parent::setUp($modules);
34

    
35
    $this->web_user = $this->drupalCreateUser($this->permissions);
36
    $this->drupalLogin($this->web_user);
37
  }
38

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

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

    
60
    return $field_name;
61
  }
62

    
63
}