1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Link base test file - contains common functions for testing links.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
class LinkBaseTestClass extends DrupalWebTestCase {
|
9 |
|
|
protected $permissions = array(
|
10 |
|
|
'access content',
|
11 |
|
|
'administer content types',
|
12 |
|
|
'administer nodes',
|
13 |
|
|
'administer filters',
|
14 |
|
|
'access comments',
|
15 |
|
|
'post comments',
|
16 |
|
|
'access administration pages',
|
17 |
|
|
'create page content',
|
18 |
|
|
);
|
19 |
|
|
|
20 |
|
|
function setUp() {
|
21 |
|
|
$modules = func_get_args();
|
22 |
|
|
$modules = (isset($modules[0]) && is_array($modules[0]) ? $modules[0] : $modules);
|
23 |
|
|
$modules[] = 'field_ui';
|
24 |
|
|
$modules[] = 'link';
|
25 |
|
|
parent::setUp($modules);
|
26 |
|
|
|
27 |
|
|
$this->web_user = $this->drupalCreateUser($this->permissions);
|
28 |
|
|
$this->drupalLogin($this->web_user);
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
protected function createLinkField($node_type = 'page', $settings = array()) {
|
32 |
|
|
$name = strtolower($this->randomName());
|
33 |
|
|
$edit = array(
|
34 |
|
|
'fields[_add_new_field][label]' => $name,
|
35 |
|
|
'fields[_add_new_field][field_name]' => $name,
|
36 |
|
|
'fields[_add_new_field][type]' => 'link_field',
|
37 |
|
|
'fields[_add_new_field][widget_type]' => 'link_field',
|
38 |
|
|
);
|
39 |
|
|
$field_name = 'field_'. $name;
|
40 |
|
|
$this->drupalPost('admin/structure/types/manage/'. $node_type .'/fields', $edit, t('Save'));
|
41 |
|
|
$this->drupalPost(NULL, array(), t('Save field settings'));
|
42 |
|
|
$this->drupalPost(NULL, $settings, t('Save settings'));
|
43 |
|
|
|
44 |
|
|
// Is field created?
|
45 |
|
|
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
|
46 |
|
|
node_types_rebuild();
|
47 |
|
|
menu_rebuild();
|
48 |
|
|
|
49 |
|
|
return $field_name;
|
50 |
|
|
}
|
51 |
|
|
} |