LinkBaseTestClass.test 1.72 KB
Newer Older
1
2
3
4
<?php

/**
 * @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
15
16
17
  /**
   * Default permissions used on tests.
   *
   * @var array
   */
18
  protected $permissions = array(
19
20
    'access content',
    'administer content types',
21
    'administer fields',
22
23
24
25
26
27
28
    'administer nodes',
    'administer filters',
    'access comments',
    'post comments',
    'access administration pages',
    'create page content',
  );
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
43
    $this->web_user = $this->drupalCreateUser($this->permissions);
    $this->drupalLogin($this->web_user);
44
  }
45

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

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

67
68
    return $field_name;
  }
69

70
}